@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #f3f4f6;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(255, 255, 255, 0.5);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --sidebar-bg: rgba(255, 255, 255, 0.9);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.dark-mode {
    --bg-color: #111827;
    --text-color: #f9fafb;
    --text-muted: #9ca3af;
    --card-bg: rgba(31, 41, 55, 0.7);
    --card-border: rgba(75, 85, 99, 0.4);
    --sidebar-bg: rgba(31, 41, 55, 0.9);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.fade-in { animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-in { animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Layout & Containers */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 768px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Gradient Backgrounds for Auth & Headers */
.bg-gradient-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: white;
}

.bg-gradient-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

/* Typography */
h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 1.5rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-3xl { font-size: 1.875rem; font-weight: 700; }
.text-4xl { font-size: 2.25rem; font-weight: 700; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-purple { color: var(--purple); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }
.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: var(--danger-hover); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }
.btn-outline { background-color: transparent; border: 1px solid var(--text-muted); color: var(--text-color); }
.btn-outline:hover { background-color: rgba(107, 114, 128, 0.1); }

/* Forms */
.input-field {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Sidebar & Admin Nav */
.admin-layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--card-border);
    width: 260px;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed { width: 80px; }
.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    transition: background 0.2s;
    border-radius: 0.5rem;
}
.nav-item:hover { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item.active:hover { background: var(--primary); }
.nav-content { flex: 1; padding: 1rem; }

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

/* Header Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
}
.nav-tabs {
    display: flex;
    gap: 1rem;
}
.nav-tab {
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}
.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}
.transaction-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--card-border);
}
.transaction-item:last-child { border-bottom: none; }

/* Utilities */
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.error-msg { background: rgba(239, 68, 68, 0.1); color: var(--danger); padding: 0.75rem; border-radius: 0.5rem; border: 1px solid var(--danger); }
.success-msg { background: rgba(16, 185, 129, 0.1); color: var(--success); padding: 0.75rem; border-radius: 0.5rem; border: 1px solid var(--success); }
.flex-wrap { flex-wrap: wrap; }
.rounded-lg { border-radius: 0.5rem; }

/* Badges & Text Sizes */
.text-xs { font-size: 0.75rem; }
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.725rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-success {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}
.badge-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}
.badge-primary {
    background-color: rgba(59, 130, 246, 0.12);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

/* Button size modifiers */
.btn-sm {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.875rem !important;
}

/* WhatsApp button */
.btn-whatsapp {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-whatsapp:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    color: #fff;
}

/* Calendar button */
.btn-calendar {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-calendar:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

/* Upcoming session card — red highlight */
.session-card-upcoming {
    border: 2px solid rgba(239, 68, 68, 0.75) !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2), var(--glass-shadow) !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease !important;
}
.session-card-upcoming:hover {
    border-color: rgba(239, 68, 68, 1) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25), var(--shadow-lg) !important;
    transform: translateY(-2px);
}

/* Action row inside each session card */
.session-card-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--card-border);
}

/* Section Header Dividers */
.player-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
    border-bottom: 2px solid var(--card-border);
    padding-bottom: 0.5rem;
    margin-top: 1.5rem;
}

.booking-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Desktop-only component classes */
.player-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.booking-item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-mobile-col {
    display: flex;
}

/* ─────────────────────────────────────────────
   MOBILE BOTTOM TAB BAR (admin, mobile only)
───────────────────────────────────────────── */
.mobile-tab-bar {
    display: none;
}

/* ─────────────────────────────────────────────
   TABLET  ≤ 900px
───────────────────────────────────────────── */
@media (max-width: 900px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ─────────────────────────────────────────────
   MOBILE  ≤ 768px
───────────────────────────────────────────── */
@media (max-width: 768px) {

    /* ── Base sizing ── */
    body {
        font-size: 15px;
    }

    h1 {
        font-size: 1.6rem;
        margin-bottom: 0.75rem;
        letter-spacing: -0.01em;
    }
    h2 {
        font-size: 1.15rem;
        margin-bottom: 0.75rem;
    }
    h3 {
        font-size: 1rem;
    }

    /* ── Container padding ── */
    .container {
        padding: 0 0.75rem;
    }

    .glass-card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    /* ── Grids ── */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    /* Stats summary: 2 per row looks better than 1 */
    .stats-grid-2,
    .grid.grid-cols-4.stats-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Booking form: 2×2 grid instead of 4 in a row */
    .booking-form-grid,
    .grid.grid-cols-4.booking-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Session card: compact on mobile */
    .session-card-upcoming {
        padding: 0.875rem !important;
    }

    /* Session card info grid: 2×2 on mobile */
    .session-card-upcoming .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Session card action buttons: stretch full width on mobile */
    .session-card-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .session-card-actions .btn,
    .session-card-actions a.btn {
        width: 100%;
        justify-content: center;
    }

    /* ── Public Navbar ── */
    .navbar {
        position: sticky;
        top: 0;
    }
    .navbar .container.flex {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
        gap: 0.5rem;
    }
    .navbar h2 {
        font-size: 1.05rem;
        white-space: nowrap;
    }
    .navbar .flex.gap-4 {
        gap: 0.5rem;
    }
    .navbar .btn {
        padding: 0.4rem 0.65rem;
        font-size: 0.8rem;
    }
    .nav-tabs {
        gap: 0;
    }
    .nav-tab {
        flex: 1;
        text-align: center;
        padding: 0.65rem 0.5rem;
        font-size: 0.85rem;
    }

    /* ── Admin layout: sidebar hides, bottom tab bar appears ── */
    .admin-layout {
        flex-direction: column;
        min-height: 100vh;
        padding-bottom: 64px; /* room for bottom tab bar */
    }

    .sidebar {
        display: none !important;
    }

    .main-content {
        padding: 0.875rem 0.75rem 1rem;
        min-height: 0;
    }

    /* ── Mobile bottom tab bar ── */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: var(--sidebar-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--card-border);
        box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .mobile-tab-bar button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 0.5rem 0.25rem;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.6rem;
        font-weight: 600;
        cursor: pointer;
        transition: color 0.2s;
        min-height: 56px;
    }
    .mobile-tab-bar button span.tab-icon {
        font-size: 1.3rem;
        line-height: 1;
    }
    .mobile-tab-bar button.active {
        color: var(--primary);
    }
    .mobile-tab-bar button.tab-logout {
        color: var(--danger);
    }

    /* ── Dark mode toggle strip in admin ── */
    .admin-topbar {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 0.75rem;
    }
    .admin-topbar .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    /* ── Cards ── */
    .booking-item-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .booking-item-card .btn-danger {
        width: 100%;
        padding: 0.6rem 1rem;
    }

    .player-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .player-card .flex.gap-2 {
        justify-content: stretch;
        flex-wrap: wrap;
    }
    .player-card .flex.gap-2 .btn {
        flex: 1;
        min-width: 0;
    }

    /* ── Booking form: 2x2 grid ── */
    .booking-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* ── Add player form ── */
    .flex-mobile-col {
        flex-direction: column;
        gap: 0.75rem;
    }
    .flex-mobile-col > * {
        width: 100% !important;
    }

    /* ── Booking quick actions ── */
    .booking-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .booking-actions .btn-primary {
        width: 100%;
    }
    .booking-actions .flex.gap-2 {
        flex-wrap: wrap;
    }
    .booking-actions .flex.gap-2 .btn {
        flex: 1;
    }

    /* ── Funds page: max-width removal ── */
    .glass-card[style*="max-width"] {
        max-width: 100% !important;
    }

    /* ── Modal ── */
    .modal-content {
        width: 95%;
        max-height: 85vh;
        border-radius: 1rem;
    }

    /* ── Login card ── */
    .container.flex.items-center.justify-center > .glass-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 1rem;
    }

    /* ── mb-8 reduced on mobile ── */
    .mb-8 {
        margin-bottom: 1.25rem;
    }

    /* ── Input sizing ── */
    .input-field {
        padding: 0.65rem 0.875rem;
        font-size: 0.95rem;
    }

    /* ── Buttons touch-target ── */
    .btn {
        min-height: 40px;
        padding: 0.5rem 0.875rem;
    }

    /* ── Text size ── */
    .text-3xl {
        font-size: 1.6rem;
    }
    .text-4xl {
        font-size: 1.8rem;
    }

    /* ── Gap utilities ── */
    .gap-6 { gap: 0.875rem; }
    .gap-4 { gap: 0.75rem; }
}

/* ─────────────────────────────────────────────
   SMALL  ≤ 480px
───────────────────────────────────────────── */
@media (max-width: 480px) {
    h1 {
        font-size: 1.4rem;
    }
    .glass-card {
        padding: 0.875rem;
    }
    .navbar h2 {
        font-size: 0.95rem;
    }
}
