/* ════════════════════════════════════════
   layout.css — Premium Sidebar Layout v4
   Najeeda Corporate Services
   ════════════════════════════════════════ */

/* ── App Shell ───────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ══════════════════════════════════════════
   SIDEBAR — Premium Design
   ══════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(160deg, #0c5225 0%, #0f6d32 22%, #0d5c2a 52%, #0b5024 78%, #094018 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 300;
    transition: width .3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    box-shadow: 3px 0 22px rgba(0,0,0,.28), 1px 0 0 rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

/* ── Sidebar Header ─────────────────────── */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 15px 14px;
    min-height: 66px;
    flex-shrink: 0;
    position: relative;
}
.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent 5%, rgba(201,168,76,.18) 50%, transparent 95%);
}

.sidebar-logo {
    width: 37px; height: 37px;
    border-radius: 9px;
    background: rgba(201,168,76,.08);
    border: 1.5px solid rgba(201,168,76,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.08rem; overflow: hidden; flex-shrink: 0;
    transition: border-color .25s, box-shadow .25s;
}
.sidebar-logo:hover {
    border-color: rgba(201,168,76,.38);
    box-shadow: 0 0 14px rgba(201,168,76,.12);
}
.sidebar-logo img { width:100%; height:100%; object-fit:cover; border-radius:7px; }

.sidebar-brand {
    flex: 1; min-width: 0;
    transition: opacity .22s, max-width .3s;
    max-width: 162px;
}
.sidebar-brand h3 {
    font-size: 0.79rem; font-weight: 800;
    color: rgba(255,255,255,.9); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; line-height: 1.25;
}
.sidebar-brand small {
    font-size: 0.6rem; color: rgba(201,168,76,.7);
    white-space: nowrap; display: block; margin-top: 1px;
    font-weight: 600; letter-spacing: 0.04em;
}
.sidebar.collapsed .sidebar-brand { opacity: 0; max-width: 0; }

.sidebar-collapse-btn {
    width: 23px; height: 23px; border-radius: 5px;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.6);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; flex-shrink: 0;
    transition: background .2s, color .2s, border-color .2s, transform .3s;
    font-family: 'Tajawal', sans-serif; line-height: 1;
}
.sidebar-collapse-btn:hover {
    background: rgba(201,168,76,.13);
    color: var(--accent);
    border-color: rgba(201,168,76,.22);
}
.sidebar.collapsed .sidebar-collapse-btn { transform: scaleX(-1); }

/* ── Sidebar Nav ────────────────────────── */
.sidebar-nav {
    flex: 1; padding: 6px 7px 4px;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.07) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.1); border-radius: 2px;
}
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

/* Group label */
.sidebar-group-label {
    font-size: 0.57rem; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: rgba(201,168,76,.62);
    padding: 13px 11px 4px;
    white-space: nowrap; overflow: hidden;
    transition: opacity .2s, max-height .3s, padding .2s;
    max-height: 36px;
}
.sidebar.collapsed .sidebar-group-label {
    opacity: 0; max-height: 0; padding: 0;
}

/* Separator */
.sidebar-sep {
    height: 1px;
    background: rgba(255,255,255,.05);
    margin: 3px 8px 4px;
}

/* Nav item */
.sidebar-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 9px;
    border-radius: 9px; cursor: pointer;
    transition: background .16s, color .16s;
    color: rgba(255,255,255,.68);
    border: none; background: transparent;
    width: 100%; text-align: left;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.83rem; font-weight: 500;
    white-space: nowrap; position: relative;
    overflow: hidden; margin-bottom: 1px;
}
.sidebar-item:hover {
    background: rgba(255,255,255,.12);
    color: rgba(255,255,255,.96);
}
.sidebar-item.active {
    background: linear-gradient(90deg, rgba(201,168,76,.17) 0%, rgba(201,168,76,.04) 100%);
    color: #cfa83a;
    font-weight: 600;
}
.sidebar-item.active::before {
    content: '';
    position: absolute; left: 0; top: 14%; bottom: 14%;
    width: 3px;
    background: linear-gradient(180deg, #d4a940 0%, rgba(201,168,76,.45) 100%);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 10px rgba(201,168,76,.4);
}

/* Icon container */
.si-icon {
    width: 28px; height: 28px;
    border-radius: 7px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .16s, transform .18s;
    background: transparent; color: inherit;
}
.si-icon svg { display: block; }

.sidebar-item:hover .si-icon {
    background: rgba(255,255,255,.07);
    transform: scale(1.06);
}
.sidebar-item.active .si-icon {
    background: rgba(201,168,76,.14);
    color: #d4a940;
    transform: none;
}

/* Label text */
.si-label {
    flex: 1; min-width: 0; overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity .2s, max-width .3s;
    max-width: 180px;
}
.sidebar.collapsed .si-label { opacity: 0; max-width: 0; }

/* Collapsed: center icons + bigger hit area */
.sidebar.collapsed .sidebar-item {
    justify-content: center; padding: 8px 6px;
}
.sidebar.collapsed .sidebar-item .si-icon {
    width: 33px; height: 33px; border-radius: 8px;
}

/* Tooltip in collapsed mode */
.sidebar.collapsed .sidebar-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%; transform: translateY(-50%);
    background: rgba(10,20,15,.96);
    border: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.88);
    font-size: 0.76rem; padding: 5px 11px;
    border-radius: 7px; white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    z-index: 500; pointer-events: none;
    font-family: 'Tajawal', sans-serif;
}

/* ── Sidebar Footer ─────────────────────── */
.sidebar-footer {
    padding: 8px 7px 10px;
    flex-shrink: 0; position: relative;
}
.sidebar-footer::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent 5%, rgba(201,168,76,.14) 50%, transparent 95%);
}

.sidebar-user-row {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: 9px;
    background: rgba(0,0,0,.12);
    margin-bottom: 7px; overflow: hidden;
    transition: background .2s;
}
.sidebar-user-row:hover { background: rgba(255,255,255,.07); }
.sidebar.collapsed .sidebar-user-row { justify-content: center; padding: 8px; }

.sidebar-avatar {
    width: 31px; height: 31px; border-radius: 50%;
    background: rgba(201,168,76,.12);
    border: 2px solid rgba(201,168,76,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.76rem; color: var(--accent);
    overflow: hidden; flex-shrink: 0; font-weight: 700;
    transition: border-color .2s;
}
.sidebar-user-row:hover .sidebar-avatar {
    border-color: rgba(201,168,76,.42);
}
.sidebar-avatar img { width:100%; height:100%; object-fit:cover; }

.sidebar-user-info {
    flex: 1; min-width: 0;
    transition: opacity .2s, max-width .3s; max-width: 165px;
}
.sidebar-user-name {
    font-size: 0.75rem; font-weight: 700;
    color: rgba(255,255,255,.88); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.64rem; color: rgba(255,255,255,.34);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 1px;
}
.sidebar.collapsed .sidebar-user-info { opacity: 0; max-width: 0; }

.sidebar-footer-btns { display: flex; gap: 5px; }

.sfb {
    flex: 1; padding: 7px 5px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px; background: transparent;
    color: rgba(255,255,255,.4); cursor: pointer;
    font-size: 0.69rem; font-family: 'Tajawal', sans-serif;
    transition: all .18s;
    display: flex; align-items: center; justify-content: center;
    gap: 5px; overflow: hidden;
}
.sfb:hover {
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.78);
    border-color: rgba(255,255,255,.15);
}
.sfb.danger:hover {
    background: rgba(220,38,38,.11);
    color: #f87171;
    border-color: rgba(220,38,38,.22);
}
.sfb svg { flex-shrink: 0; }
.sfb .sfb-label {
    white-space: nowrap; overflow: hidden;
    transition: opacity .2s, max-width .3s; max-width: 80px;
}
.sidebar.collapsed .sfb { flex: none; width: 37px; padding: 7px; }
.sidebar.collapsed .sfb .sfb-label { opacity: 0; max-width: 0; }

/* ── Sidebar Pin Toggle ──────────────────── */
.sidebar-pin {
    position: fixed;
    left: calc(var(--sidebar-w) - 11px);
    top: 62px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid rgba(255,255,255,.3);
    color: white; font-size: 0.78rem; font-weight: 700;
    cursor: pointer; z-index: 302;
    display: flex; align-items: center; justify-content: center;
    transition: left .3s cubic-bezier(.4,0,.2,1), background .2s, transform .2s;
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
    line-height: 1; padding: 0;
    font-family: 'Tajawal', sans-serif;
}
.sidebar-pin::before { content: '‹'; }
.sidebar-pin:hover { background: var(--accent); transform: scale(1.18); }
.sidebar.collapsed ~ .sidebar-pin {
    left: calc(var(--sidebar-collapsed-w) - 11px);
}
.sidebar.collapsed ~ .sidebar-pin::before { content: '›'; }
@media (max-width: 768px) { .sidebar-pin { display: none; } }

/* ── Sidebar Mobile Overlay ─────────────── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.56);
    z-index: 298;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: sbOverlayIn .2s ease;
}
.sidebar-overlay.show { display: block; }

@keyframes sbOverlayIn { from { opacity: 0; } to { opacity: 1; } }

/* ══════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left .3s cubic-bezier(.4,0,.2,1);
    display: flex; flex-direction: column;
    background: var(--gray-100);
    min-width: 0; flex: 1;
}
.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-w);
}

/* ── Mobile Topbar ──────────────────────── */
.mobile-topbar {
    display: none;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    padding: 0 14px;
    align-items: center; gap: 11px;
    position: sticky; top: 0; z-index: 200;
    box-shadow: 0 2px 14px rgba(0,0,0,.18);
    flex-shrink: 0;
}
.hamburger-btn {
    width: 34px; height: 34px; border: none;
    background: rgba(255,255,255,.14); border-radius: 8px;
    color: white; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s; flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,.24); }
.mobile-page-title {
    flex: 1; font-size: 0.88rem; font-weight: 700; color: white;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mobile-topbar-logo {
    width: 30px; height: 30px; border-radius: 7px;
    background: rgba(255,255,255,.12); overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0;
}
.mobile-topbar-logo img { width:100%; height:100%; object-fit:cover; }

/* ── Content Area ───────────────────────── */
.content-area {
    padding: 22px 20px; flex: 1; min-width: 0;
}

/* ── Tab Pane ───────────────────────────── */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ══════════════════════════════════════════
   SECTION CARDS
   ══════════════════════════════════════════ */
.section, .section-card {
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow); margin-bottom: 20px;
    border: 1px solid var(--gray-200); overflow: hidden;
}
.section-head {
    padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between;
}
.section-head h3 { font-size: 0.95rem; font-weight: 700; color: white; }
.sh-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.sh-admin   { background: linear-gradient(135deg, #1e1b4b, #3730a3); }
.sh-red     { background: linear-gradient(135deg, #7f1d1d, var(--danger)); }
.sh-green   { background: linear-gradient(135deg, #064e3b, var(--success)); }
.sh-gold    { background: linear-gradient(135deg, #78350f, var(--warning)); }
.sh-gray    { background: linear-gradient(135deg, #374151, #6b7280); }
.section-title {
    font-size: 0.9rem; font-weight: 700; color: var(--gray-700);
    padding: 12px 0 8px;
}
.section-body { padding: 18px; }

/* ══════════════════════════════════════════
   STATS & QUICK GRIDS
   ══════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 20px;
}
.stat-card {
    background: white; border-radius: var(--radius-lg);
    padding: 20px 18px; box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    cursor: pointer; transition: var(--tr);
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute;
    top: 0; right: 0; width: 4px; height: 100%;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.stat-card.blue::after   { background: var(--primary); }
.stat-card.gold::after   { background: var(--accent); }
.stat-card.green::after  { background: var(--success); }
.stat-card.red::after    { background: var(--danger); }
.stat-card.purple::after { background: var(--purple); }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-icon  { font-size: 2.2rem; margin-bottom: 10px; }
.stat-label { font-size: 0.8rem; color: var(--gray-500); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.9rem; font-weight: 900; color: var(--primary); line-height: 1; }
.stat-value.gold   { color: var(--accent-dark); }
.stat-value.green  { color: var(--success); }
.stat-value.red    { color: var(--danger); }
.stat-value.purple { color: var(--purple); }
.stat-sub { font-size: 0.75rem; color: var(--gray-400); margin-top: 4px; }

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 20px;
}
.quick-card {
    background: white; border-radius: var(--radius-lg);
    padding: 18px 14px; text-align: center;
    cursor: pointer; box-shadow: var(--shadow);
    border: 1px solid var(--gray-200); transition: var(--tr);
}
.quick-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}
.quick-card .qi { font-size: 2rem; display: block; margin-bottom: 8px; }
.quick-card .qt { font-weight: 700; font-size: 0.9rem; color: var(--gray-800); }
.quick-card .qs { font-size: 0.76rem; color: var(--gray-400); margin-top: 3px; }

/* ── mt-4 utility ───────────────────────── */
.mt-4 { margin-top: 16px; }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1280px) {
    :root { --sidebar-w: 240px; }
}

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 258px !important;
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        box-shadow: 5px 0 32px rgba(0,0,0,.42);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .mobile-topbar { display: flex; }
    .sidebar-collapse-btn { display: none; }
    .content-area { padding: 14px 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .section-head { padding: 12px 14px; }
}

@media (max-width: 480px) {
    .stats-grid { gap: 8px; }
    .quick-grid { gap: 8px; grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 14px 12px; }
    .stat-icon { font-size: 1.8rem; margin-bottom: 6px; }
    .stat-value { font-size: 1.5rem; }
    .content-area { padding: 10px 8px; }
    .section-body { padding: 12px; }
    .quick-card { padding: 14px 10px; }
    .quick-card .qi { font-size: 1.6rem; margin-bottom: 5px; }
    /* Section head wraps on small screens */
    .section-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .section-head h3 { font-size: 0.88rem; }
}

/* Extra small: 320px */
@media (max-width: 360px) {
    .content-area { padding: 8px 6px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .quick-grid  { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-value  { font-size: 1.25rem; }
    .stat-card   { padding: 12px 10px; }
    .section-head { padding: 8px 10px; }
}

/* Prevent .section overflow: hidden from clipping mobile card rows */
@media (max-width: 640px) {
    .section, .section-card { overflow: visible; }
    /* Re-apply clip only to section-head for rounded corners */
    .section-head, .modal-head { overflow: hidden; }
}
