/* ═══════════════════════════════════════════════════════
   layout.css — چیدمان داشبورد (سایدبار + تاپبار + محتوا)
   ═══════════════════════════════════════════════════════ */

/* ─── پوشش کلی ─────────────────────────────────────────── */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

/* ─── سایدبار ───────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
    transition: transform .3s ease;
    border-left: 1px solid rgba(255,255,255,.05);
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar-logo {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}
.sidebar-logo img {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-sm);
}
.sidebar-logo-text { font-size: .9rem; font-weight: 600; color: #fff; line-height: 1.3; }
.sidebar-logo-sub  { font-size: .7rem; color: var(--sidebar-text); margin-top: .1rem; }

.sidebar-nav     { padding: .75rem 0; flex: 1; }
.sidebar-section { margin-bottom: .25rem; }

.sidebar-section-title {
    padding: .5rem 1rem .25rem;
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(148,163,184,.5);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1rem;
    color: var(--sidebar-text);
    font-size: .875rem;
    transition: var(--transition);
    cursor: pointer;
    border-right: 3px solid transparent;
    text-decoration: none;
}
.sidebar-item:hover  { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-item.active {
    background: rgba(29,78,216,.15);
    color: #fff;
    border-right-color: var(--primary);
}

.sidebar-item-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    opacity: .8;
}
.sidebar-item.active .sidebar-item-icon { opacity: 1; }

/* گروه‌بندی سایدبار (زیرمنو) */
.sidebar-item-row { display: flex; align-items: stretch; }
.sidebar-item-row .sidebar-item { flex: 1; }
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sidebar-text);
    padding: 0 .875rem;
    font-size: .7rem;
    transition: var(--transition);
}
.sidebar-toggle-btn:hover { color: #e2e8f0; }
.sidebar-group.open .sidebar-toggle-btn { transform: rotate(180deg); }
.sidebar-submenu { display: none; }
.sidebar-group.open .sidebar-submenu { display: block; }
.sidebar-subitem { padding-right: 2.5rem; font-size: .82rem; }

.sidebar-item-badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    padding: .1rem .4rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar-footer {
    padding: .875rem 1rem;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}
.sidebar-user-avatar {
    width: 2rem; height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 600;
    flex-shrink: 0;
}
.sidebar-user-name { font-size: .8rem; color: #e2e8f0; font-weight: 500; }
.sidebar-user-role { font-size: .7rem; color: var(--sidebar-text); }
.sidebar-logout {
    margin-right: auto;
    color: var(--sidebar-text);
    font-size: .875rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: var(--transition);
    text-decoration: none;
}
.sidebar-logout:hover { color: var(--danger); }

/* ─── محتوای اصلی ───────────────────────────────────────── */
.main-content {
    margin-right: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ─── نوار بالا ─────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0; z-index: 100;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: var(--shadow-xs);
    flex-shrink: 0;
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-left  { display: flex; align-items: center; gap: .75rem; }
.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.topbar-breadcrumb { font-size: .8rem; color: var(--text-muted); }

.hamburger-btn {
    display: none;
    width: 2.25rem; height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    font-size: 1.1rem;
    transition: var(--transition);
}
.hamburger-btn:hover { background: var(--surface-3); }

.notif-btn {
    position: relative;
    width: 2.25rem; height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    transition: var(--transition);
    text-decoration: none;
}
.notif-btn:hover { background: var(--surface-3); color: var(--text); }

.notif-badge {
    position: absolute;
    top: -4px; left: -4px;
    width: 1rem; height: 1rem;
    background: var(--danger);
    border-radius: 50%;
    font-size: .6rem;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    border: 2px solid #fff;
}

.topbar-avatar {
    width: 2rem; height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 600;
    cursor: pointer;
}

/* ─── محتوای صفحه ───────────────────────────────────────── */
.page-content  { padding: 1.5rem; flex: 1; }
.page-header   {
    margin-bottom: 1.5rem;
    display: flex; align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; gap: .75rem;
}
.page-title    { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin-top: .2rem; }

/* ─── گرید آمار ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ─── نوار فیلتر ────────────────────────────────────────── */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex; align-items: center;
    gap: .75rem; flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filter-bar .form-control { max-width: 200px; }

/* ─── پوشش موبایل ───────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
}

/* ─── ریسپانسیو ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar             { transform: translateX(100%); }
    .sidebar.open        { transform: translateX(0); }
    .sidebar-overlay.show{ display: block; }
    .main-content        { margin-right: 0; }
    .topbar              { padding: 0 1rem; }
    .page-content        { padding: 1rem; }
    .hamburger-btn       { display: flex; }
}

@media (max-width: 768px) {
    .stats-grid             { grid-template-columns: repeat(2,1fr); }
    .filter-bar             { flex-direction: column; align-items: stretch; }
    .filter-bar .form-control{ max-width: none; }
    .page-header            { flex-direction: column; align-items: flex-start; }
    .table                  { font-size: .8rem; }
    .table thead th,
    .table tbody td         { padding: .625rem; }
}

@media (max-width: 480px) {
    .stats-grid  { grid-template-columns: 1fr; }
    .steps .step-label { display: none; }
}

/* ─── لایه‌بندی سایت عمومی ──────────────────────────────── */
.site-wrapper   { min-height: 100vh; display: flex; flex-direction: column; }
.site-main      { flex: 1; }

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-xs);
}
.site-header-inner {
    max-width: 1200px; margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex; align-items: center; justify-content: space-between;
    position: relative;
}

/* دکمه همبرگر (سه‌خط) — فقط در موبایل نمایش داده می‌شود */
.site-nav-toggle {
    display: none;
    flex-direction: column; align-items: stretch; justify-content: center; gap: 5px;
    width: 2.25rem; height: 2.25rem;
    background: none; border: none; cursor: pointer; padding: 0;
}
.site-nav-toggle span {
    display: block; width: 100%; height: 2px;
    background: var(--text); border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.site-nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-nav-toggle.open span:nth-child(2) { opacity: 0; }
.site-nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.site-brand {
    display: flex; align-items: center; gap: .75rem;
    font-weight: 700; font-size: 1.05rem; color: var(--text);
    text-decoration: none;
}
.site-brand img { width: 2rem; height: 2rem; border-radius: var(--radius-sm); }

.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav a {
    padding: .4rem .875rem;
    font-size: .875rem;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
}
.site-nav a:hover { background: var(--surface-3); color: var(--text); }

/* منوی کشویی (زیرمنو) در نوار بالای سایت */
.site-nav-dropdown { position: relative; }
.site-nav-dropdown-toggle {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .4rem .875rem;
    font-size: .875rem;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
    cursor: pointer;
    background: none; border: none;
}
.site-nav-dropdown:hover .site-nav-dropdown-toggle,
.site-nav-dropdown-toggle:hover { background: var(--surface-3); color: var(--text); }
.site-nav-dropdown-menu {
    display: none;
    position: absolute; top: 100%; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    min-width: 180px;
    padding: .375rem;
    z-index: 200;
}
.site-nav-dropdown:hover .site-nav-dropdown-menu,
.site-nav-dropdown:focus-within .site-nav-dropdown-menu { display: block; }
.site-nav-dropdown-menu a {
    display: block;
    padding: .5rem .75rem;
    font-size: .85rem;
    color: var(--text);
    border-radius: var(--radius-sm);
    text-decoration: none;
}
.site-nav-dropdown-menu a:hover { background: var(--surface-3); }

@media (max-width: 768px) {
    .site-nav-toggle { display: flex; }
    .site-nav {
        display: none;
        position: absolute; top: 100%; right: 0; left: 0;
        flex-direction: column; align-items: stretch; gap: .125rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
        padding: .5rem;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
    }
    .site-nav.open { display: flex; }
    .site-nav a { width: 100%; padding: .75rem 1rem; }
    .site-nav .btn { text-align: center; }
    .site-nav-dropdown { position: static; width: 100%; }
    .site-nav-dropdown-toggle { width: 100%; padding: .75rem 1rem; justify-content: space-between; }
    .site-nav-dropdown:hover .site-nav-dropdown-menu { display: none; }
    .site-nav-dropdown-menu {
        position: static;
        box-shadow: none; border: none;
        background: var(--surface-2);
        margin-bottom: .25rem;
        min-width: 0;
        padding: .25rem;
    }
    .site-nav-dropdown.open .site-nav-dropdown-menu { display: block; }
}

.site-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 2.5rem 1.5rem 1.5rem;
    margin-top: auto;
}
.site-footer-inner {
    max-width: 1200px; margin: 0 auto;
    display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr));
    gap: 2rem; padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.site-footer-bottom {
    max-width: 1200px; margin: 1rem auto 0;
    font-size: .8rem; text-align: center;
}
.footer-title { color: #e2e8f0; font-weight: 600; margin-bottom: .75rem; font-size: .9rem; }
.footer-link  { display: block; color: #64748b; font-size: .85rem; margin-bottom: .4rem; text-decoration: none; }
.footer-link:hover { color: #94a3b8; }

/* ─── فلش پیام ─────────────────────────────────────────── */
.flash-messages { padding: .75rem 1.5rem 0; }
