/* ============================================================
   WATi Chess - Student Tracker Stylesheet
   Fully Responsive for Desktop, Tablet & Mobile Devices
   ============================================================ */

:root {
    --primary: #1e293b;
    --primary-hover: #0f172a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
    background-color: var(--primary);
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    position: relative;
    z-index: 1000;
}

.nav-brand-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: auto;
}

.navbar .brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.nav-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s;
    user-select: none;
}

.nav-toggle:hover,
.nav-toggle:active {
    background: rgba(255, 255, 255, 0.22);
}

.navbar .nav-links {
    display: flex;
    gap: 8px;
    list-style: none;
    align-items: center;
    flex-wrap: wrap;
}

.navbar .nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-block;
}

.navbar .nav-links a:hover,
.navbar .nav-links a.active {
    background-color: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.user-nav-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 10px;
}

.user-pill {
    background: rgba(255, 255, 255, 0.15);
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 0.82rem;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.btn-logout {
    background: #ef4444;
    color: white !important;
    text-decoration: none;
    padding: 6px 12px !important;
    border-radius: 6px;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #dc2626 !important;
}

/* ============================================================
   Layout & Containers
   ============================================================ */
.container {
    width: 100%;
    max-width: 1120px;
    margin: 28px auto;
    padding: 0 20px;
    flex: 1;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h1 {
    font-size: 1.65rem;
    color: var(--primary);
    font-weight: 800;
    line-height: 1.25;
}

/* ============================================================
   Dashboard Grids & Cards
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: #eff6ff;
    color: var(--accent);
    flex-shrink: 0;
}

.stat-info {
    min-width: 0;
}

.stat-info h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-info .stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 3px;
    line-height: 1.1;
}

/* Action Cards */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.action-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.action-card h3 {
    font-size: 1.15rem;
    color: var(--primary);
    margin-bottom: 6px;
}

.action-card p {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

/* Base Card Container */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 22px;
}

/* Responsive Split Grid (Students, Classes pages) */
.responsive-split-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 25px;
    align-items: start;
}

/* Form Helper Grids */
.form-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-dates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ============================================================
   Forms & Controls
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    line-height: 1.3;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* ============================================================
   Tables & Data
   ============================================================ */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    margin-bottom: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 500px;
}

table th {
    background-color: #f8fafc;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
    vertical-align: middle;
}

table tbody tr:last-child td {
    border-bottom: none;
}

table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-purple  { background: #f3e8ff; color: #7e22ce; }

/* Progress Bar */
.progress-container {
    width: 100%;
    background-color: #e2e8f0;
    border-radius: 9999px;
    height: 12px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-bar.complete {
    background-color: var(--success);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.92rem;
    line-height: 1.45;
}

.alert-success {
    background-color: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.alert-danger {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-info {
    background-color: #e0f2fe;
    border: 1px solid #bae6fd;
    color: #0369a1;
}

footer {
    text-align: center;
    padding: 22px 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: #ffffff;
}

/* ============================================================
   RESPONSIVE MEDIA QUERIES (Mobile, Tablet, Small Screens)
   ============================================================ */

/* Large Tablets & Medium Screens (<= 920px) */
@media (max-width: 920px) {
    .navbar {
        padding: 12px 18px;
        flex-direction: column;
        align-items: stretch;
    }

    .nav-brand-container {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .navbar .nav-links {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding-top: 14px;
        margin-top: 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        width: 100%;
    }

    .navbar .nav-links.nav-open {
        display: flex;
        animation: mobileNavFade 0.2s ease-out;
    }

    .navbar .nav-links a {
        padding: 11px 14px;
        border-radius: 8px;
        font-size: 0.95rem;
        background: rgba(255, 255, 255, 0.05);
        display: block;
    }

    .navbar .nav-links a:hover,
    .navbar .nav-links a.active {
        background: var(--accent);
        color: white;
    }

    .nav-user-item {
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        list-style: none;
    }

    .user-nav-badge {
        margin-left: 0;
        justify-content: space-between;
        width: 100%;
    }

    .responsive-split-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Standard Mobile & Tablet (<= 768px) */
@media (max-width: 768px) {
    .container {
        padding: 0 14px;
        margin: 16px auto;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    .page-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .page-header > div:last-child .btn {
        flex: 1 1 auto;
        text-align: center;
    }

    .card {
        padding: 18px 15px;
        margin-bottom: 18px;
        border-radius: 12px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
        border-radius: 10px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        border-radius: 8px;
    }

    .stat-info h3 {
        font-size: 0.72rem;
    }

    .stat-info .stat-value {
        font-size: 1.3rem;
    }

    .action-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .action-card {
        padding: 18px 16px;
    }

    /* iOS Friendly Inputs (prevents zoom in) */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px;
        padding: 11px 12px;
    }

    .btn {
        padding: 11px 16px;
        font-size: 0.92rem;
    }

    .btn-mobile-full {
        width: 100% !important;
        margin-top: 8px;
    }

    .chart-container-responsive {
        height: 250px !important;
    }
}

/* Smartphone View (<= 600px) */
@media (max-width: 600px) {
    .form-cards-grid {
        grid-template-columns: 1fr !important;
    }

    .form-dates-grid {
        grid-template-columns: 1fr !important;
    }

    .filter-bar-responsive {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .filter-bar-responsive form,
    .filter-bar-responsive select {
        width: 100% !important;
    }
}

/* Small Smartphone View (<= 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
        margin: 12px auto;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .card {
        padding: 15px 12px;
        border-radius: 10px;
    }

    .dashboard-grid {
        gap: 8px;
    }

    .stat-card {
        padding: 12px 10px;
        gap: 8px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }

    .stat-info .stat-value {
        font-size: 1.2rem;
    }

    .btn-preset {
        flex: 1 1 calc(50% - 6px);
        text-align: center;
        padding: 8px 6px !important;
        font-size: 0.8rem !important;
    }
}

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