/* ===== 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: 58px;
    --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;
}

.premium-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}

.premium-header-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    flex: 0 0 auto;
    filter: drop-shadow(0 8px 20px rgba(104, 160, 255, 0.18));
}

.premium-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.premium-header-kicker {
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #8ecbff;
}

.premium-header-name {
    font-family: 'Sora', sans-serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--accent-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 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;
}

.more-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.more-sheet-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.more-sheet {
    position: fixed;
    left: 50%;
    bottom: calc(var(--footer-height) + var(--safe-area-bottom) + 10px);
    transform: translateX(-50%) translateY(16px);
    width: min(100% - 24px, 520px);
    max-height: calc(100dvh - var(--header-height) - var(--safe-area-top) - var(--footer-height) - var(--safe-area-bottom) - 28px);
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(20, 24, 39, 0.98), rgba(11, 14, 24, 0.98));
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 30px 80px rgba(0,0,0,0.45);
    padding: 16px;
    display: flex;
    flex-direction: column;
    z-index: 1201;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.more-sheet.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.more-sheet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding-right: 2px;
}

.more-sheet-card {
    align-items: center;
    text-decoration: none;
    padding: 16px;
    min-height: 98px;
    justify-content: center;
    text-align: center;
    gap: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.04);
}

.more-sheet-card i {
    width: 24px;
    height: 24px;
    color: var(--accent-gold);
}

.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;
}

.field-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.field-row {
    position: relative;
}

.field-row .input-premium {
    padding-right: 42px;
}

.validation-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.12);
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.validation-dot.is-valid {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

.validation-dot.is-invalid {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.field-hint {
    font-size: 11px;
    color: var(--text-secondary);
}

.details-card {
    border: 1px solid rgba(201, 168, 76, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.details-card summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
}

.details-card summary::-webkit-details-marker {
    display: none;
}

.details-card[open] summary {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.details-content {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.helper-button {
    background: rgba(201, 168, 76, 0.12);
    color: var(--accent-gold);
    border: 1px solid rgba(201, 168, 76, 0.24);
    border-radius: 10px;
    padding: 0 14px;
    min-height: 42px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

/* 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;
}

input.input-premium[readonly] {
    opacity: 0.84;
}

/* --- 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;
}
