:root {
    --brand: #2f6feb;
    --brand-dark: #1f4fb0;
    --brand-light: #eaf1fe;
    --bg: #f3f5fa;
    --sidebar-from: #0f1c3f;
    --sidebar-via: #17265c;
    --sidebar-to: #1f4fb0;
    --card-radius: 16px;
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, .06);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, .10);
    --shadow-lg: 0 20px 48px rgba(15, 23, 42, .14);
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background-color: var(--bg);
}

a { text-decoration: none; }

/* ===================== App Shell / Sidebar ===================== */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 268px;
    flex-shrink: 0;
    background: linear-gradient(195deg, var(--sidebar-from), var(--sidebar-via) 55%, var(--sidebar-to));
    color: rgba(255, 255, 255, .78);
    flex-direction: column;
    padding: 1.35rem 1.1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 10px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: #fff;
    font-weight: 800;
    font-size: 1.08rem;
    padding: .4rem .3rem 1.6rem;
}
.sidebar-brand-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.14);
    border-radius: 12px;
    font-size: 1.1rem;
    color: #fff;
}

.sidebar-nav { display: flex; flex-direction: column; gap: .3rem; flex: 1; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .68rem .9rem;
    border-radius: 12px;
    color: rgba(255,255,255,.75);
    font-size: .92rem;
    transition: background .15s, color .15s, transform .15s;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-link:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar-link.active {
    background: rgba(255,255,255,.18);
    color: #fff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #fff;
}

.sidebar-user { border-top: 1px solid rgba(255,255,255,.14); padding-top: 1rem; margin-top: 1rem; }
.sidebar-user-card { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.sidebar-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.16);
    color: #fff; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-avatar-sm { width: 30px; height: 30px; font-size: .85rem; background: var(--brand-light); color: var(--brand-dark); }

.sidebar-avatar.avatar-has-img,
.sidebar-avatar-sm.avatar-has-img {
    padding: 0;
    overflow: hidden;
    background: transparent;
}
.sidebar-avatar img,
.sidebar-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-avatar-lg { width: 120px; height: 120px; }
.profile-avatar-circle {
    width: 120px; height: 120px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 2.6rem;
    font-weight: 700;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.profile-avatar-circle.avatar-has-img { background: transparent; }
.profile-avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-name { color: #fff; font-size: .87rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.sidebar-user-role { color: rgba(255,255,255,.6); font-size: .75rem; }
.sidebar-logout {
    display: flex; align-items: center; gap: .5rem;
    color: rgba(255,255,255,.75);
    font-size: .85rem;
    padding: .5rem .3rem;
    transition: color .15s;
}
.sidebar-logout:hover { color: #fff; }

.sidebar-offcanvas { background: linear-gradient(195deg, var(--sidebar-from), var(--sidebar-via) 55%, var(--sidebar-to)); color: #fff; width: 280px; }
.sidebar-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }

/* ===================== Main content / Topbar ===================== */
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .85rem 1.5rem;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(8px);
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 1.05rem; font-weight: 800; margin: 0; color: #101828; }
.btn-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-light); color: var(--brand-dark); border: none;
}
.today-chip {
    background: var(--brand-light); color: var(--brand-dark);
    padding: .4rem .8rem; border-radius: 999px; font-size: .82rem; font-weight: 600;
    align-items: center; gap: .4rem;
}
.topbar-user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: #fff; border: 1px solid #eef0f4; border-radius: 999px;
    padding: .3rem .9rem .3rem .3rem;
}

.content-inner { padding: 1.6rem; flex: 1; animation: fadeIn .25s ease; }
.content-inner-guest { min-height: 100vh; }

.app-footer { text-align: center; color: #94a3b8; font-size: .8rem; padding: 1.2rem; }

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

/* ===================== Cards ===================== */
.card {
    border: none;
    box-shadow: var(--shadow-sm);
    border-radius: var(--card-radius);
    transition: box-shadow .2s, transform .2s;
}

.stat-card {
    border-radius: 18px;
    color: #fff;
    padding: 1.2rem 1.4rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card i.stat-icon {
    position: absolute; left: 1rem; top: 1rem;
    font-size: 1.6rem; opacity: .35;
}
.stat-card .stat-number { font-size: 2rem; font-weight: 800; line-height: 1.2; }
.stat-card .stat-label { opacity: .92; font-size: .85rem; margin-top: .15rem; }

.bg-grad-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.bg-grad-red    { background: linear-gradient(135deg, #f87171, #b91c1c); }
.bg-grad-orange { background: linear-gradient(135deg, #fbbf24, #b45309); }
.bg-grad-green  { background: linear-gradient(135deg, #34d399, #15803d); }
.bg-grad-purple { background: linear-gradient(135deg, #a78bfa, #6d28d9); }
.bg-grad-teal   { background: linear-gradient(135deg, #2dd4bf, #0f766e); }

.chart-card { padding: 1.3rem; }
.chart-legend-item { display: flex; align-items: center; justify-content: space-between; padding: .4rem 0; font-size: .88rem; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-left: .5rem; }

.table-row-overdue { background-color: #fdecec !important; }
.table-row-today { background-color: #fff6e0 !important; }

.badge-status { font-size: .78rem; padding: .4em .75em; border-radius: 999px; }

.btn-call, .btn-chat { white-space: nowrap; }

/* ===================== Auth pages (login/register) ===================== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}
.auth-visual {
    flex: 1.1;
    background: linear-gradient(160deg, var(--sidebar-from), var(--sidebar-via) 55%, var(--sidebar-to));
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 3.5rem;
    position: relative;
    overflow: hidden;
}
.auth-visual::before, .auth-visual::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
}
.auth-visual::before { width: 340px; height: 340px; top: -120px; left: -100px; }
.auth-visual::after { width: 240px; height: 240px; bottom: -80px; left: 40%; background: rgba(255,255,255,.05); }
.auth-visual-content { position: relative; z-index: 1; max-width: 460px; }
.auth-visual-icon {
    width: 56px; height: 56px; border-radius: 16px;
    background: rgba(255,255,255,.14);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; margin-bottom: 1.5rem;
}
.auth-visual h2 { font-weight: 800; font-size: 1.7rem; margin-bottom: .8rem; }
.auth-visual p { color: rgba(255,255,255,.75); font-size: .95rem; line-height: 1.9; }
.auth-feature-list { list-style: none; padding: 0; margin: 1.8rem 0 0; display: flex; flex-direction: column; gap: .9rem; }
.auth-feature-list li { display: flex; align-items: center; gap: .7rem; font-size: .9rem; color: rgba(255,255,255,.85); }
.auth-feature-list i { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.auth-mini-chart { display: flex; align-items: flex-end; gap: 6px; height: 70px; margin-top: 2rem; }
.auth-mini-chart span { flex: 1; background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.35)); border-radius: 6px 6px 2px 2px; }

.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 2.4rem 2.2rem;
    animation: fadeIn .35s ease;
}
.auth-card.auth-card-wide {
    max-width: 480px;
}
.auth-card h4 { font-weight: 800; }
.auth-card .form-control, .auth-card .form-select {
    border-radius: 10px;
    padding: .65rem .9rem;
    border-color: #e5e9f2;
}
.auth-card .btn-primary {
    border-radius: 10px;
    padding: .7rem 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border: none;
    box-shadow: 0 8px 20px rgba(47,111,235,.35);
}

@media (max-width: 991.98px) {
    .auth-visual { display: none; }
    .stat-number { font-size: 1.6rem; }
}
