/* ===== THEME SYSTEM ===== */
:root,
[data-theme="dark"] {
    --bg-deep: #111111;
    --bg-surface: #1A1A1A;
    --bg-card: #222222;
    --accent-gold: #C9A84C;
    --accent-purple: #7C5CFC;
    --text-primary: #F0F0F0;
    --text-secondary: #888888;
    --input-bg: rgba(255, 255, 255, 0.04);
    --input-border: rgba(255, 255, 255, 0.06);
    --header-bg: rgba(17, 17, 17, 0.92);
    --footer-bg: rgba(17, 17, 17, 0.95);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --btn-primary-text: #111;
    --select-bg: #222222;
    --select-text: #F0F0F0;
    --header-height: 56px;
    --footer-height: 64px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.15);
    --radius: 12px;
}

[data-theme="light"] {
    --bg-deep: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #f1f5f9;
    --accent-gold: #b8860b;
    --accent-purple: #6d28d9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --input-bg: #f1f5f9;
    --input-border: #e2e8f0;
    --header-bg: rgba(248, 250, 252, 0.92);
    --footer-bg: rgba(248, 250, 252, 0.95);
    --border-subtle: rgba(15, 23, 42, 0.06);
    --btn-primary-text: #fff;
    --select-bg: #ffffff;
    --select-text: #0f172a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overscroll-behavior-y: contain;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}

html {
    background-color: var(--bg-deep);
}

h1,
h2,
h3,
.font-sora {
    font-family: 'Sora', sans-serif;
}

.mobile-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    background-color: var(--bg-deep);
}

/* --- Header --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--header-height) + var(--safe-area-top));
    padding-top: var(--safe-area-top);
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 20px;
    padding-right: 20px;
    z-index: 1000;
}

header h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--accent-gold);
    letter-spacing: -0.01em;
}

/* --- Footer Navigation --- */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--footer-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--footer-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    gap: 3px;
    transition: color 0.2s;
}

.tab-item.active {
    color: var(--accent-gold);
}

.tab-item i {
    width: 22px;
    height: 22px;
}

/* --- Content Area --- */
main {
    flex: 1;
    margin-top: calc(var(--header-height) + var(--safe-area-top));
    margin-bottom: calc(var(--footer-height) + var(--safe-area-bottom));
    padding: 16px;
}

/* --- Cards --- */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background-color 0.3s;
}

/* --- Buttons --- */
.btn-primary {
    background-color: var(--accent-gold);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 10px;
    height: 42px;
    padding: 0 20px;
    font-weight: 600;
    font-size: 13px;
    width: 100%;
    cursor: pointer;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:active {
    opacity: 0.75;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    height: 42px;
    font-weight: 500;
    font-size: 13px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* --- Inputs & Selects (FIX: readable in both themes) --- */
.input-premium {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

/* Selects get a custom arrow */
select.input-premium {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 11px 40px 11px 14px;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.input-premium:focus {
    outline: none;
    border-color: rgba(201, 168, 76, 0.4);
}

select.input-premium option {
    background: var(--select-bg);
    color: var(--select-text);
}

textarea.input-premium {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    font-family: inherit;
}

/* --- Avatar --- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 15px;
    border: none;
    flex-shrink: 0;
}

.athlete-info {
    flex: 1;
    min-width: 0;
}

.athlete-info h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.athlete-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Bottom Sheet --- */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-surface);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    padding: 16px 20px;
    padding-bottom: calc(20px + var(--safe-area-bottom));
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: rgba(128, 128, 128, 0.2);
    border-radius: 2px;
    margin: 0 auto 14px;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1999;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Theme Toggle Button --- */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.theme-toggle:hover {
    color: var(--accent-gold);
}

/* --- Utils --- */
.text-gold {
    color: var(--accent-gold);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-xs {
    font-size: 12px;
}

.font-semibold {
    font-weight: 600;
}