/* =========================================================
   Helm Academy CRM — Design System
   Warm + Professional palette suitable for kids' academy
   ========================================================= */

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

:root {
    /* Backgrounds */
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-3: #eef1f7;

    /* Brand colors (warm purple/teal for academy) */
    --primary: #5b67ea;
    --primary-soft: #e6e9ff;
    --primary-ink: #3a47c4;
    --primary-dark: #2e3aa3;

    /* Accents */
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --info: #0284c7;
    --info-soft: #e0f2fe;

    /* Chip palette */
    --amber: #f59e0b;
    --amber-soft: #fef3c7;
    --mint: #10b981;
    --mint-soft: #d1fae5;
    --coral: #ef4444;
    --coral-soft: #fee2e2;
    --sky: #0ea5e9;
    --sky-soft: #e0f2fe;
    --orange: #f97316;
    --orange-soft: #ffedd5;
    --rose: #ec4899;
    --rose-soft: #fce7f3;

    /* Text */
    --ink: #1a1d2e;
    --ink-2: #4a4f6b;
    --mute: #8b91a8;

    /* Lines & shadows */
    --line: #e5e8f0;
    --line-2: #d4d9e6;
    --shadow-sm: 0 1px 2px rgba(20, 25, 60, 0.04), 0 2px 8px rgba(20, 25, 60, 0.04);
    --shadow-md: 0 4px 12px rgba(20, 25, 60, 0.06), 0 12px 24px rgba(20, 25, 60, 0.06);
    --shadow-lg: 0 8px 24px rgba(20, 25, 60, 0.08), 0 24px 48px rgba(20, 25, 60, 0.08);

    /* Misc */
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    direction: rtl;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

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

/* ─── Layout ───────────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 20px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8b7eff);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(91, 103, 234, 0.3);
}

.brand-text {
    line-height: 1.3;
}

.brand-text b {
    display: block;
    font-size: 15px;
    color: var(--ink);
}

.brand-text small {
    font-size: 11.5px;
    color: var(--mute);
}

.nav-section {
    padding: 16px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--mute);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 8px;
    border-radius: 10px;
    color: var(--ink-2);
    font-weight: 500;
    font-size: 13.5px;
    transition: all .15s;
}

.nav-link:hover {
    background: var(--surface-2);
    color: var(--primary-ink);
}

.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary-ink);
    font-weight: 600;
}

.nav-link .ico {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    font-size: 16px;
    opacity: .9;
}

.nav-link .badge {
    margin-inline-start: auto;
    background: var(--coral);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 10.5px;
    font-weight: 600;
}

/* ─── Main area ───────────────────────────────────────── */
.main {
    min-width: 0;
    padding: 0 24px 32px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 64px;
    padding: 0 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.topbar-search {
    flex: 1;
    max-width: 360px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 38px 10px 14px;
    font: inherit;
    color: var(--ink);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.topbar-search::before {
    content: '🔍';
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    opacity: .5;
}

.profile-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 12px 6px 6px;
    font-size: 13px;
    font-weight: 500;
}

.role-badge {
    background: var(--primary-soft);
    color: var(--primary-ink);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
}

.role-badge.admin { background: var(--primary-soft); color: var(--primary-ink); }
.role-badge.employee { background: var(--mint-soft); color: #047857; }

/* ─── Page head ───────────────────────────────────────── */
.page-head {
    margin-bottom: 20px;
}

.page-head.with-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 4px;
}

.page-head .sub {
    color: var(--mute);
    font-size: 13.5px;
}

.page-head .count {
    color: var(--mute);
    font-weight: 400;
}

/* ─── Cards ────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card.compact { padding: 14px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mt-10 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-10 { margin-bottom: 10px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ─── KPIs ─────────────────────────────────────────────── */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all .15s;
}

.kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi .ico {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 20px;
    flex-shrink: 0;
}

.kpi b {
    display: block;
    font-size: 22px;
    line-height: 1.2;
    color: var(--ink);
    font-weight: 800;
}

.kpi small {
    display: block;
    font-size: 11.5px;
    color: var(--mute);
    margin-top: 2px;
}

.kpi.lg b { font-size: 28px; }

/* ─── Chips ───────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.chip-primary { background: var(--primary-soft); color: var(--primary-ink); }
.chip-amber   { background: var(--amber-soft); color: #92400e; }
.chip-mint    { background: var(--mint-soft); color: #047857; }
.chip-coral   { background: var(--coral-soft); color: #b91c1c; }
.chip-sky     { background: var(--sky-soft); color: #075985; }
.chip-orange  { background: var(--orange-soft); color: #c2410c; }
.chip-rose    { background: var(--rose-soft); color: #be185d; }
.chip-success { background: var(--success-soft); color: #15803d; }
.chip-warning { background: var(--warning-soft); color: #92400e; }
.chip-danger  { background: var(--danger-soft); color: #b91c1c; }
.chip-info    { background: var(--info-soft); color: #0369a1; }
.chip-gray    { background: var(--surface-3); color: var(--ink-2); }

.chip-line { background: transparent; border: 1.5px solid var(--line-2); color: var(--ink-2); }

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 18px;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.lg { padding: 12px 24px; font-size: 14px; }
.btn.full { width: 100%; }
.btn.ghost {
    background: transparent;
    color: var(--ink-2);
    border-color: var(--line-2);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.warning { background: var(--warning); color: #fff; }

/* ─── Forms ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}

.field label .req { color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    padding: 10px 14px;
    font: inherit;
    color: var(--ink);
    transition: border .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.input:disabled {
    background: var(--surface-2);
    color: var(--mute);
}

.textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.field-help {
    font-size: 11.5px;
    color: var(--mute);
    margin-top: 4px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

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

/* ─── Avatars ──────────────────────────────────────────── */
.avi {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-ink);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    text-transform: uppercase;
    overflow: hidden;
}

.avi.sm { width: 28px; height: 28px; font-size: 11px; }
.avi.lg { width: 48px; height: 48px; font-size: 16px; }
.avi.xl { width: 64px; height: 64px; font-size: 22px; }

/* ─── Tables ──────────────────────────────────────────── */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.tbl {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.tbl th {
    background: var(--surface-2);
    color: var(--ink-2);
    font-weight: 600;
    font-size: 12px;
    text-align: start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.tbl td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    color: var(--ink);
    vertical-align: middle;
}

.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* ─── Auth pages ──────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #f4f6fb 0%, #e6e9ff 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    text-align: center;
}

.auth-card .brand-mark {
    margin: 0 auto 16px;
    width: 56px;
    height: 56px;
    font-size: 24px;
}

.auth-card h1 {
    font-size: 22px;
    margin-bottom: 6px;
}

.auth-card p {
    color: var(--mute);
    font-size: 13px;
    margin: 0 0 24px;
}

.auth-card .field { text-align: start; }

/* ─── Alerts ──────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert.success { background: var(--success-soft); color: #15803d; border-color: var(--success); }
.alert.danger  { background: var(--danger-soft); color: #b91c1c; border-color: var(--danger); }
.alert.warning { background: var(--warning-soft); color: #92400e; border-color: var(--warning); }
.alert.info    { background: var(--info-soft); color: #075985; border-color: var(--info); }

/* ─── Pipeline (Sales Kanban-style) ──────────────────── */
.pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.pipeline-col {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 100px;
}

.pipeline-col .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.pipeline-col .head b {
    font-size: 12.5px;
    font-weight: 700;
}

.pipeline-col .count {
    background: var(--primary-soft);
    color: var(--primary-ink);
    border-radius: 100px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

/* ─── Pagination ──────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-2);
    padding: 8px 14px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all .15s;
}

.pagination a:hover { background: var(--surface-2); }
.pagination a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ─── Filters ─────────────────────────────────────────── */
.filters {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filters label { font-size: 12px; color: var(--mute); font-weight: 600; }

.filter-input {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
}

/* ─── Empty state ─────────────────────────────────────── */
.empty {
    text-align: center;
    padding: 60px 20px;
}

.empty .ico {
    font-size: 64px;
    margin-bottom: 12px;
    opacity: .4;
}

.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--mute); font-size: 13px; margin: 0 0 20px; }

/* ─── Toast ───────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    inset-inline-start: 24px;
    background: var(--ink);
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    font-size: 13.5px;
    font-weight: 500;
    animation: slideUp .3s ease;
}

.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }
.toast.warning { background: var(--warning); color: #fff; }

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

/* ─── Modal ───────────────────────────────────────────── */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(20, 25, 60, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-bg.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 { font-size: 18px; margin-bottom: 8px; }

/* ─── Mobile ──────────────────────────────────────────── */
@media (max-width: 980px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        z-index: 100;
        width: 260px;
        transform: translateX(100%);
        transition: transform .25s;
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: block; }
    .main { padding: 0 16px 24px; }
}

/* ─── Utility ─────────────────────────────────────────── */
.text-mute { color: var(--mute); }
.text-ink-2 { color: var(--ink-2); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }

/* ─── Print ───────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .filters { display: none !important; }
    .main { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
