/* =========================================================
   Design Tokens
   رنگ‌های primary/ink به‌صورت پویا از طریق تنظیمات مدیر
   در header.php بازنویسی می‌شوند؛ مقادیر اینجا فقط پیش‌فرض‌اند.
   ========================================================= */
:root {
    --color-primary: #EE5C0D;
    --color-primary-hover: #D14F09;
    --color-primary-light: #FDEEE3;
    --color-ink: #1D3046;
    --color-ink-soft: #3A4E63;

    --color-success: #1E7E4B;
    --color-success-bg: #E7F5EC;
    --color-warning: #B8790F;
    --color-warning-bg: #FBF0DD;
    --color-danger: #B23B2E;
    --color-danger-bg: #FBEAE7;
    --color-info: #2E6C8E;
    --color-info-bg: #E8F1F6;

    --color-surface: #F7F5F3;
    --color-surface-alt: #FFFFFF;
    --color-border: #E4E0DB;
    --color-text: #23201C;
    --color-text-muted: #6B655D;

    --font-family: 'Vazirmatn', Tahoma, sans-serif;
    --text-page-title: 22px;
    --text-section-title: 17px;
    --text-card-title: 15px;
    --text-body: 14px;
    --text-caption: 12.5px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    --radius-sm: 8px;
    --radius-md: 14px;

    --shadow-sm: 0 1px 2px rgba(29,48,70,.07), 0 1px 1px rgba(29,48,70,.04);
    --shadow-md: 0 12px 32px rgba(29,48,70,.16);

    --sidebar-width: 236px;
}

/* ===== Reset / base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: var(--font-family);
    background: var(--color-surface);
    color: var(--color-text);
    margin: 0;
    direction: rtl;
    font-size: var(--text-body);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}
input[type="checkbox"], input[type="radio"] {
    width: 19px;
    height: 19px;
    accent-color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

h1, h2, h3, h4 { margin: 0 0 var(--space-3); color: var(--color-ink); font-weight: 700; }

/* ===== App shell (sidebar + main) ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--color-ink);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.sidebar-club-name { font-weight: 700; font-size: 15px; color: #fff; }

.sidebar-nav { padding: var(--space-3) var(--space-2); display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.78);
    font-size: 14px;
    transition: background .15s ease, color .15s ease;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active { background: var(--color-primary); color: #fff; font-weight: 600; }

.sidebar-footer { padding: var(--space-3); border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user { font-size: 12.5px; color: rgba(255,255,255,.65); padding: 0 var(--space-3) var(--space-2); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    background: var(--color-surface-alt);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    position: sticky;
    top: 0;
    z-index: 10;
}
.page-title { font-size: var(--text-page-title); margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-4); }
.topbar-actions a { color: var(--color-text-muted); font-size: 13.5px; }
.topbar-actions a:hover { color: var(--color-primary); }

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-ink);
}

.app-content { max-width: 1100px; width: 100%; margin: 0 auto; padding: var(--space-5); flex: 1; }

/* ===== Cards & panels ===== */
.card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}
.card h2 { font-size: var(--text-section-title); }

.panel {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
    overflow: hidden;
}
.panel-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.panel-header h2 { font-size: var(--text-section-title); margin: 0; }
.panel-body { padding: var(--space-5); }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); flex-wrap: wrap; gap: var(--space-3); }

/* ===== Class cards grid ===== */
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-4); }
.class-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.class-actions { display: flex; gap: var(--space-3); font-size: 13px; margin-top: var(--space-1); }

.btn-enter {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--color-primary);
    color: #fff;
    padding: var(--space-3) 0;
    border-radius: var(--radius-sm);
    margin-top: var(--space-2);
    font-weight: 600;
    transition: background .15s ease;
}
.btn-enter:hover { background: var(--color-primary-hover); color: #fff; }

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-tertiary, .btn-success, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn-primary:disabled { background: #E9C7AE; cursor: not-allowed; }

.btn-secondary { background: var(--color-surface-alt); color: var(--color-ink); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-surface); color: var(--color-ink); }

.btn-tertiary { background: transparent; color: var(--color-primary); padding-inline: var(--space-2); }
.btn-tertiary:hover { text-decoration: underline; color: var(--color-primary-hover); }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #176B3F; color: #fff; }

.btn-danger { background: var(--color-surface-alt); color: var(--color-danger); border-color: #F0D2CC; }
.btn-danger:hover { background: var(--color-danger-bg); }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.8;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-neutral { background: var(--color-surface); color: var(--color-text-muted); }

/* ===== Forms ===== */
.field-group { margin-bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.field-group label { font-size: 13.5px; color: var(--color-text-muted); font-weight: 500; }
.field-group .required::after { content: ' *'; color: var(--color-danger); }

.field-group input[type="text"],
.field-group input[type="password"],
.field-group input[type="number"],
.field-group input[type="tel"],
.field-group select {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--color-surface-alt);
    color: var(--color-text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field-group input:focus, .field-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.field-group input:disabled, .field-group select:disabled { background: var(--color-surface); color: var(--color-text-muted); cursor: not-allowed; }
.field-group input.field-error { border-color: var(--color-danger); }
.field-group input[type="color"] { width: 60px; height: 40px; padding: 2px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: none; }
.field-group input[type="file"] { padding: var(--space-2) 0; border: none; background: none; }
.field-hint { font-size: var(--text-caption); color: var(--color-text-muted); }
.field-error-msg { font-size: var(--text-caption); color: var(--color-danger); }

.jalali-date-select { display: flex; gap: var(--space-2); }
.jalali-date-select select { flex: 1; }

.logo-preview { padding: var(--space-2); }
.logo-preview img { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); padding: var(--space-2); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.simple-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.simple-table thead th {
    text-align: right;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.simple-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}
.simple-table tbody tr:hover { background: var(--color-surface); }
.simple-table tbody tr:last-child td { border-bottom: none; }
.simple-table tbody tr.row-incomplete { background: var(--color-warning-bg); }
.simple-table tbody tr.row-incomplete:hover { background: #F5E4C3; }

/* ===== Alerts (dismissible) ===== */
.alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    font-size: 14px;
    animation: alert-in .2s ease;
}
@keyframes alert-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-close { background: none; border: none; cursor: pointer; font-size: 16px; color: inherit; opacity: .6; line-height: 1; }
.alert-close:hover { opacity: 1; }

.alert-card { border-color: var(--color-warning); }
.alert-card h2 { color: var(--color-warning); margin-top: 0; }
.notif-class-heading { font-size: var(--text-card-title); margin: var(--space-4) 0 var(--space-2); color: var(--color-ink); border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-1); }
.notif-class-heading:first-of-type { margin-top: 0; }
.notif-list { display: flex; flex-direction: column; gap: var(--space-2); }
.notif-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}
.notif-row:last-child { border-bottom: none; }
.notif-row form { flex-shrink: 0; }
.notif-text { flex: 1; min-width: 0; word-break: break-word; }
@media (max-width: 560px) {
    .notif-row { flex-direction: column; align-items: stretch; }
    .notif-row form { width: 100%; }
    .notif-row .btn-primary { width: 100%; }
}

/* ===== خلاصه‌ی آماری (برچسب/مقدار) — بدون جدول، برای جلوگیری از اسکرول افقی ناخواسته در موبایل ===== */
.stat-list { display: flex; flex-direction: column; }
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--color-text-muted); }
.stat-row strong { color: var(--color-ink); font-weight: 700; white-space: nowrap; }

/* ===== جدول‌های واکنش‌گرا: زیر ۶۴۰px به کارت‌های عمودی تبدیل می‌شوند تا دکمه/چک‌باکس هر ردیف همیشه، بدون نیاز به اسکرول افقی، دیده شود ===== */
@media (max-width: 640px) {
    .table-wrap-stack { overflow-x: visible; }
    .simple-table.stack-mobile { min-width: 0; width: 100%; }
    .simple-table.stack-mobile thead { display: none; }
    .simple-table.stack-mobile, .simple-table.stack-mobile tbody, .simple-table.stack-mobile tr, .simple-table.stack-mobile td {
        display: block;
        width: 100%;
    }
    .simple-table.stack-mobile tr {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        margin-bottom: var(--space-3);
        padding: var(--space-1) var(--space-3);
    }
    .simple-table.stack-mobile tr:last-child { margin-bottom: 0; }
    .simple-table.stack-mobile td {
        border-bottom: 1px dashed var(--color-border);
        padding: var(--space-2) 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        text-align: left;
    }
    .simple-table.stack-mobile td:last-child { border-bottom: none; }
    .simple-table.stack-mobile td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text-muted);
        font-size: var(--text-caption);
        flex-shrink: 0;
        text-align: right;
    }
    .simple-table.stack-mobile td:not([data-label]) { justify-content: flex-start; }
    .simple-table.stack-mobile td form { width: 100%; display: flex; justify-content: flex-end; margin: 0; }
    .simple-table.stack-mobile td form .btn-primary,
    .simple-table.stack-mobile td form .btn-danger,
    .simple-table.stack-mobile td form .btn-secondary { width: 100%; }
}

/* ===== Checkbox lists ===== */
.checkbox-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.checkbox-item { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; }

.inline-form { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
.inline-form input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.muted { color: var(--color-text-muted); font-size: 14px; }

.star-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.star-input input { position: absolute; opacity: 0; width: 0; height: 0; }
.star-input label { font-size: 20px; color: var(--color-border); cursor: pointer; line-height: 1; }
.star-input input:checked ~ label,
.star-input label:hover,
.star-input label:hover ~ label { color: var(--color-warning); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--color-text-muted); }
.empty-state svg { margin-bottom: var(--space-2); opacity: .5; }

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(29,48,70,.45);
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--color-surface-alt);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-5);
    max-width: 360px;
    width: 90%;
}
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }

/* ===== Login page ===== */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--color-surface); padding: var(--space-4); }
.login-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-6) var(--space-5);
    width: 100%;
    max-width: 360px;
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); }
.login-logo img { width: 64px; height: 64px; object-fit: contain; }
.login-logo span { font-weight: 700; color: var(--color-ink); font-size: 16px; }

.login-switch { display: flex; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: var(--space-5); }
.switch-btn { flex: 1; padding: var(--space-3); border: none; background: var(--color-surface); cursor: pointer; font-family: inherit; font-size: 14px; color: var(--color-text-muted); }
.switch-btn.active { background: var(--color-primary); color: #fff; }
.register-link { display: block; text-align: center; margin-top: var(--space-4); font-size: 14px; }

.register-cta {
    display: block;
    text-align: center;
    margin-top: var(--space-5);
    padding: var(--space-4);
    background: var(--color-primary);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background .15s ease;
}
.register-cta:hover { background: var(--color-primary-hover); color: #fff; }

.footer { text-align: center; padding: var(--space-5); color: var(--color-text-muted); font-size: var(--text-caption); }

/* ===== آواتار ===== */
.avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
    background: var(--color-surface);
}
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    vertical-align: middle;
    margin-inline-end: var(--space-2);
}
.avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 700;
}
.avatar-placeholder.avatar-sm { display: inline-flex; }
.profile-photo-row { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }
.player-cell { display: flex; align-items: center; }

/* ===== ویزارد ثبت‌نام سه‌مرحله‌ای ===== */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    counter-reset: step;
}
.wizard-steps .step {
    flex: 1;
    text-align: center;
    font-size: var(--text-caption);
    color: var(--color-text-muted);
    position: relative;
    padding-top: 38px;
}
.wizard-steps .step::before {
    counter-increment: step;
    content: counter(step);
    display: block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    margin: 0 auto var(--space-2);
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(50%);
}
.wizard-steps .step.active { color: var(--color-ink); font-weight: 700; }
.wizard-steps .step.active::before { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.wizard-steps .step.done::before { background: var(--color-success); border-color: var(--color-success); color: #fff; content: '✓'; }
.wizard-step-body { display: none; }
.wizard-step-body.active { display: block; }
.wizard-actions { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-5); }
.wizard-actions .btn-primary, .wizard-actions .btn-secondary { flex: 1; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
    .sidebar-toggle { display: block; }
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        transform: translateX(100%);
        transition: transform .2s ease;
        z-index: 90;
        box-shadow: var(--shadow-md);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; }
    .sidebar-backdrop.open { display: block; }
    .app-content { padding: var(--space-4); }
    .app-topbar { padding: var(--space-3) var(--space-4); }
    .page-title { font-size: 18px; }
    .topbar-actions span.user-name { display: none; }
}
