* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* FightTrack Color Palette */
    --primary: #E63946;      /* Fist Red */
    --primary-dark: #D12F3B; /* Darker red for hover */
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #F5F5F5;   /* Light Gray */
    --surface: #FFFFFF;      /* White */
    --text: #1D1D1D;         /* Dark Charcoal */
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Loading Screen */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Screen Management */
.screen {
    display: none !important;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Auth Screen */
#loginScreen.active {
    min-height: 100vh;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #1D1D1D; /* Dark Charcoal background */
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 48px;
    padding-top: 200px; /* Extra padding at top for logo */
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    width: 100%;
    text-align: center;
    overflow: visible; /* Allow logo to extend outside */
    position: relative;
}

.logo {
    margin-bottom: 40px;
    margin-top: -180px; /* Pull logo up into the extra padding space */
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo img {
    display: block;
    margin: 0 auto;
    max-width: 100%; /* Prevent logo from overflowing */
    height: auto;
}

.nav-brand img {
    display: block;
}

.auth-card h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
    letter-spacing: 1px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Forms */
.auth-form {
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.helper-text {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px; /* Rounded corners 6-8px */
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Roboto', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--surface); /* White */
    color: var(--text); /* Dark text */
    border: 2px solid var(--primary); /* Red border */
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary); /* Red background on hover */
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-google {
    background: white;
    color: #3c4043;
    border: 1px solid #dadce0;
    width: 100%;
}

.btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-google svg {
    flex-shrink: 0;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span {
    padding: 0 12px;
    font-weight: 500;
}

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* Navbar */
.navbar {
    background: #1D1D1D; /* Dark Charcoal */
    border-bottom: 1px solid rgba(230, 57, 70, 0.3);
    padding: 20px 0; /* Increased padding for larger logo */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--surface); /* White text */
    letter-spacing: 1px;
}

.nav-brand svg {
    flex-shrink: 0;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Main Content */
main {
    padding: 32px 24px;
}

.section {
    margin-bottom: 32px;
}

.section:first-child {
    margin-top: 24px;
}

.section-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.section-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.section-header .btn {
    white-space: nowrap;
    width: auto;
    flex-shrink: 0;
}

.section-header .btn-primary {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--primary);
}

.section-header .btn-primary:hover {
    background: var(--primary);
    color: white;
}

.section-header .btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 2px solid var(--border);
}

.section-header .btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-secondary);
}

/* Profile Card */
.profile-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.profile-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.profile-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-item label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-item span {
    font-size: 16px;
    color: var(--text);
}

/* Subscriptions List */
.subscriptions-list {
    display: grid;
    gap: 16px;
}

.subscription-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.subscription-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.subscription-group-header {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 24px;
    margin-bottom: 12px;
    padding: 8px 16px;
    border-radius: 8px;
    display: inline-block;
}

.subscription-group-header:first-child {
    margin-top: 0;
}

.subscription-group-header.group-athletes {
    background: #fef3c7;
    color: #92400e;
}

.subscription-group-header.group-teams {
    background: #d1fae5;
    color: #065f46;
}

.subscription-group-header.group-brackets {
    background: #fce7f3;
    color: #9f1239;
}

.subscription-info {
    flex: 1;
}

.subscription-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.subscription-type.self {
    background: #dbeafe;
    color: #1e40af;
}

.subscription-type.athlete {
    background: #fef3c7;
    color: #92400e;
}

.subscription-type.team,
.subscription-type.club {
    background: #d1fae5;
    color: #065f46;
}

.subscription-type.category {
    background: #fce7f3;
    color: #9f1239;
}

.subscription-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.subscription-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

.subscription-actions {
    display: flex;
    gap: 8px;
}

.subscription-actions .btn {
    padding: 8px 16px;
    font-size: 14px;
}

.subscription-actions .btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 2px solid var(--border);
}

.subscription-actions .btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-secondary);
}

/* Quick Subscribe Buttons */
.btn-quick {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    padding: 16px 20px;
    justify-content: flex-start;
    text-align: left;
    font-size: 15px;
    transition: all 0.2s;
}

.btn-quick:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--primary);
    transform: translateX(4px);
}

.btn-quick:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-quick.subscribed {
    background: #f0fdf4;
    border-color: #86efac;
}

.btn-quick .emoji {
    font-size: 20px;
    margin-right: 12px;
}

/* Quick Subscription Loading */
.quick-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.quick-loading .spinner {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
}

.quick-loading p {
    font-size: 14px;
    margin: 0;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-secondary);
}

.empty-state svg {
    opacity: 0.4;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

/* Search */
.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-box input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-results {
    display: grid;
    gap: 12px;
}

.search-result-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.search-result-card:hover {
    border-color: var(--primary);
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.search-result-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-header .modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-header .modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-footer .btn {
    width: auto;
    min-width: 120px;
}

.modal-footer .btn-primary {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--primary);
}

.modal-footer .btn-primary:hover {
    background: var(--primary);
    color: white;
}

.modal-footer .btn-secondary {
    background: var(--background);
    color: var(--text);
    border: 2px solid var(--border);
}

.modal-footer .btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-secondary);
}

.preference-group {
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .auth-card {
        padding: 32px 24px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-header .btn {
        width: 100%;
    }
    
    .profile-info {
        grid-template-columns: 1fr;
    }
    
    .subscription-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .subscription-actions {
        width: 100%;
    }
    
    .subscription-actions .btn {
        flex: 1;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-box {
        flex-direction: column;
    }
    
    /* Calendar sidebar becomes top bar on mobile */
    .app-container {
        flex-direction: column;
    }
    
    .calendar-sidebar {
        width: 100%;
        height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .main-content {
        width: 100%;
    }
}

/* Calendar Sidebar */
.app-container {
    display: flex;
    min-height: calc(100vh - 64px); /* Subtract navbar height */
    padding: 20px;
    gap: 20px;
}

.calendar-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 24px; /* Gap between children */
}

.calendar-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(50vh - 60px);
}

.results-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(50vh - 60px);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--background);
    color: var(--primary);
}

.calendar-list {
    padding: 0;
    overflow-y: auto; /* Scroll within the card */
    flex: 1; /* Take remaining space */
}

/* Recent Results Section */
.sidebar-section {
    /* Removed - now using .results-container */
}

.results-list {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.athlete-result {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    transition: background 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.athlete-result:hover {
    background: var(--background);
}

.athlete-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.medal-summary {
    display: flex;
    gap: 12px;
    align-items: center;
}

.medal-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}

.medal-icon {
    font-size: 18px;
}

.medal-item[title]:hover {
    cursor: help;
}

.calendar-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.calendar-empty {
    padding: 40px 20px;
    text-align: center;
}

.calendar-empty svg {
    color: var(--text-secondary);
    opacity: 0.5;
    margin-bottom: 12px;
}

.calendar-empty h4 {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 8px;
}

.calendar-empty p {
    font-size: 14px;
    color: var(--text-secondary);
}

.calendar-tournament {
    border-bottom: 1px solid var(--border);
}

.tournament-header {
    padding: 16px 20px 12px;
    background: var(--background);
    border-top: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.tournament-header:hover {
    background: #f1f5f9;
}

.tournament-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.tournament-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.tournament-date .days-away {
    font-weight: 600;
    color: var(--primary);
}

.tournament-matches {
    background: var(--surface);
}

.calendar-match {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    transition: background 0.2s;
    cursor: pointer;
}

.calendar-match:hover {
    background: var(--background);
}

.calendar-match.my-match {
    background: #eff6ff;
    border-left: 3px solid var(--primary);
    padding-left: 17px;
}

.calendar-match.my-match:hover {
    background: #dbeafe;
}

.match-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.calendar-match.my-match .match-time {
    color: var(--primary);
}

.match-fighters {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
    font-weight: 500;
}

.calendar-match.my-match .match-fighters {
    font-weight: 600;
}

.match-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.match-category {
    display: block;
    margin-bottom: 2px;
}

.match-location {
    display: inline-block;
}

.main-content {
    flex: 1;
    overflow-y: auto;
}

.main-content.container {
    max-width: 1200px;
    margin: 0;
    padding: 0;
}

/* Admin Panel Tabs */
.admin-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab:hover {
    color: var(--text);
    background: var(--background);
}

.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.admin-tab-content {
    animation: fadeIn 0.3s ease-in-out;
}

