:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --secondary: #0ea5e9;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1e2433;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(30, 36, 51, 0.06);
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    direction: rtl;
    font-size: 15px;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Layout: Auth pages ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 20px;
}
.auth-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    padding: 40px 34px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-card .logo {
    text-align: center;
    margin-bottom: 22px;
}
.auth-card .logo .icon {
    width: 60px; height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
    font-size: 26px; color: #fff;
}
.auth-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.auth-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; margin-bottom: 6px; font-weight: 600; color: var(--text); }
.form-control {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
    border-radius: 10px; font-family: inherit; font-size: 14px;
    transition: border-color .15s, box-shadow .15s; background: #fafbfc;
}
.form-control:focus {
    outline: none; border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
select.form-control { cursor: pointer; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 20px; border-radius: 10px; border: none; font-family: inherit;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #e5e7eb; color: var(--text); }

.auth-links { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.auth-links a { color: var(--primary); font-weight: 600; }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---------- Dashboard layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); background: #171b2d; color: #cbd2e6;
    position: fixed; top: 0; right: 0; bottom: 0; overflow-y: auto; z-index: 50;
    transition: transform .2s;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 10px; padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand .icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
}
.sidebar .brand span { font-weight: 700; font-size: 14.5px; color: #fff; }
.sidebar nav { padding: 14px 10px; }
.sidebar .nav-section { font-size: 11px; color: #6b7280; padding: 14px 10px 6px; text-transform: uppercase; letter-spacing: .05em; }
.sidebar a.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    font-size: 13.5px; margin-bottom: 2px; color: #cbd2e6; transition: background .15s, color .15s;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.nav-link.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; }
.sidebar a.nav-link .badge-count {
    margin-right: auto; background: var(--danger); color: #fff; font-size: 10.5px;
    padding: 1px 7px; border-radius: 20px;
}

.main-content { margin-right: var(--sidebar-w); flex: 1; min-width: 0; }

.topbar {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 14px 26px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
}
.topbar h2 { font-size: 17px; margin: 0; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; }
.topbar .avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }

.page-body { padding: 24px 26px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px; border: 1px solid var(--border);
}
.stat-card .icon {
    width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff; flex-shrink: 0;
}
.stat-card .value { font-size: 22px; font-weight: 800; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); }

.card {
    background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border); margin-bottom: 22px;
}
.card .card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card .card-header h3 { font-size: 15px; margin: 0; }
.card .card-body { padding: 20px; }

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th, table.data-table td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data-table th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; background: #fafbfd; }
table.data-table tr:hover td { background: #f9fafc; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e5e7eb; color: #374151; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: .4; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs a { padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 160px); background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.chat-list { border-left: 1px solid var(--border); overflow-y: auto; }
.chat-list .contact { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-list .contact:hover, .chat-list .contact.active { background: #f4f6fb; }
.chat-list .contact .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--secondary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.chat-list .contact .meta { min-width: 0; }
.chat-list .contact .meta .name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .contact .meta .role { font-size: 11.5px; color: var(--text-muted); }
.chat-main { display: flex; flex-direction: column; }
.chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #f9fafc; }
.msg-bubble { max-width: 65%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.6; }
.msg-bubble.out { align-self: flex-start; background: var(--primary); color: #fff; border-bottom-left-radius: 3px; }
.msg-bubble.in { align-self: flex-end; background: #fff; border: 1px solid var(--border); border-bottom-right-radius: 3px; }
.msg-bubble .time { font-size: 10.5px; opacity: .7; margin-top: 4px; display: block; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; }

/* ---------- Landing ---------- */
.navbar-public {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 6%; background: #fff; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100;
}
.navbar-public .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.navbar-public .brand .icon { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; color: #fff; }
.hero { padding: 70px 6% 90px; text-align: center; background: radial-gradient(circle at top, #eef1ff, var(--bg)); }
.hero h1 { font-size: 34px; margin-bottom: 14px; }
.hero p { color: var(--text-muted); font-size: 15.5px; max-width: 560px; margin: 0 auto 28px; line-height: 1.9; }
.hero .cta { display: flex; gap: 12px; justify-content: center; }
.features { padding: 60px 6%; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px; max-width: 1200px; margin: 0 auto; }
.feature-card { background: #fff; border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.feature-card .icon { width: 46px; height: 46px; border-radius: 12px; background: #eef1ff; color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 14px; }
.feature-card h3 { font-size: 15px; margin-bottom: 8px; }
.feature-card p { font-size: 13px; color: var(--text-muted); line-height: 1.8; margin: 0; }
.footer-public { text-align: center; padding: 24px; color: var(--text-muted); font-size: 12.5px; border-top: 1px solid var(--border); }

/* ---------- Jalali Datepicker ---------- */
.jdate-popup {
    position: absolute; z-index: 500; background: #fff; border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.18); padding: 12px; width: 260px;
}
.jdate-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 700; font-size: 13.5px; }
.jdate-nav { background: #f4f6fb; border: none; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.jdate-nav:hover { background: #e5e7eb; }
.jdate-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.jdate-wd { text-align: center; font-size: 11px; color: var(--text-muted); padding: 4px 0; }
.jdate-day { text-align: center; font-size: 12.5px; padding: 7px 0; border-radius: 8px; cursor: pointer; }
.jdate-day:hover { background: var(--primary); color: #fff; }
.jdate-day.today { border: 1.5px solid var(--primary); font-weight: 700; }

/* ---------- Weekly calendar ---------- */
.week-calendar-wrap { overflow-x: auto; }
.week-calendar { display: grid; min-width: 760px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.week-calendar .wc-cell { border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); padding: 6px; min-height: 56px; position: relative; }
.week-calendar .wc-head { background: #fafbfd; text-align: center; font-weight: 700; font-size: 12.5px; padding: 10px 4px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.week-calendar .wc-time { background: #fafbfd; font-size: 11px; color: var(--text-muted); text-align: center; padding: 6px; border-bottom: 1px solid var(--border); }
.wc-class-block { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; border-radius: 8px; padding: 5px 7px; font-size: 11px; margin-bottom: 3px; line-height: 1.5; }

/* ---------- Print (karnameh / report) ---------- */
@media print {
    .sidebar, .topbar, .no-print, .btn, form.filter-form { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .page-body { padding: 0 !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .menu-toggle { display: block; }
}
