/* ============================================================
   SUPERADMIN — GLOBAL
   The only shared stylesheet. Loaded on every superadmin page.
   Design tokens + app shell + universal primitives (buttons, inputs,
   base table, badges, pagination). Page-specific design lives in each
   page's own file: sa-dashboard.css, sa-users.css, sa-forms.css ...
   Everything scoped under .sa-portal so the user portal is untouched.
   ============================================================ */

.sa-portal {
    --sa-bg: #f2f8f4;
    --sa-bg-2: #eaf4ee;
    --sa-card: #ffffff;
    --sa-primary: #2f9d6f;
    --sa-primary-dark: #227a54;
    --sa-primary-soft: #e6f6ec;
    --sa-ink: #1f4d38;
    --sa-orange: #ff9466;
    --sa-purple: #9b7fe0;
    --sa-blue: #57addd;
    --sa-yellow: #ffc857;
    --sa-text: #2a333c;
    --sa-muted: #8a94a3;
    --sa-border: #e7eee9;

    --sa-radius-lg: 16px;
    --sa-radius: 12px;
    --sa-radius-sm: 8px;

    --sa-pad: 1.05rem;
    --sa-pad-lg: 1.35rem;
    --sa-gap: 0.85rem;

    --sa-shadow: 0 8px 22px rgba(34, 122, 84, 0.08);
    --sa-shadow-sm: 0 2px 8px rgba(34, 122, 84, 0.05);

    font-family: "Inter", "Segoe UI", sans-serif;
    font-size: 12px;
    color: var(--sa-text);
    background-color: var(--sa-bg);
}

/* ---------- Corner-gap fix ---------- */
html:has(body.sa-portal) {
    background: var(--sa-bg);
    height: 100%;
    overflow: hidden;   /* stop the native/unstyled outer scrollbar */
}
body.sa-portal {
    margin: 0;
    height: 100%;
    background: var(--sa-bg);
    overflow: hidden;   /* body itself never scrolls */
}
.sa-portal .app-wrapper {
    background: var(--sa-bg);
    align-items: stretch;
    height: 100vh;      /* was min-height — now fixed so it doesn't grow the page */
    display: flex;
}

/* ---------- Headings ---------- */
.sa-portal h1, .sa-portal h2, .sa-portal h3, .sa-portal h4 {
    font-family: "Quicksand", "Inter", sans-serif;
    font-weight: 700;
    color: var(--sa-ink);
    letter-spacing: 0.01em;
    margin-bottom: 0;
}
.sa-portal h1 { font-size: 1.1rem; }
.sa-portal h2 { font-size: 0.98rem; }
.sa-portal h3 { font-size: 0.86rem; }

/* ---------- Main content frame (the ONLY scrollable region) ---------- */
.sa-portal .main-content {
    padding: 1rem 0.7rem 1rem;
    margin: 0 auto;
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}
.sa-portal .main-content > .mb-3 { margin-bottom: 1rem !important; }

/* ---------- Sidebar (sticky, full height) ---------- */
.sa-portal .sidebar {
    background: var(--sa-card);
    border-right: 1px solid var(--sa-border);
    box-shadow: 1px 0 14px rgba(0,0,0,0.02);
    padding: 1.15rem 0.85rem;
    width: 218px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    flex-shrink: 0;
    overflow-y: auto;   /* only scrolls internally if its own links overflow */
    overflow-x: hidden;
}
.sa-portal .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: "Quicksand", sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--sa-text);
    border-bottom: 1px solid var(--sa-border);
    padding: 0 0.25rem 0.9rem;
    margin-bottom: 0.6rem;
}
.sa-portal .sidebar .brand-icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--sa-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.sa-portal .sidebar a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--sa-muted);
    border-left: none;
    border-radius: var(--sa-radius-sm);
    margin: 0.15rem 0;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.sa-portal .sidebar a i { font-size: 0.9rem; width: 17px; text-align: center; }
.sa-portal .sidebar a:hover {
    background: var(--sa-primary-soft);
    color: var(--sa-primary-dark);
    border-left-color: transparent;
}
.sa-portal .sidebar a.active {
    background: var(--sa-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 11px rgba(47,157,111,0.26);
}

/* sidebar footer: user chip + logout, pinned bottom */
.sa-portal .sa-sidebar-footer {
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid var(--sa-border);
}
.sa-portal .sa-sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.35rem 0.7rem;
}
.sa-portal .sa-sidebar-user .sa-avatar {
    width: 30px; height: 30px;
    margin-right: 0;
    font-size: 0.72rem;
    flex-shrink: 0;
}
.sa-portal .sa-sidebar-user-meta { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.sa-portal .sa-sidebar-user-meta strong {
    font-size: 0.78rem;
    color: var(--sa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sa-portal .sa-sidebar-user-meta small { font-size: 0.64rem; color: var(--sa-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.sa-portal .sa-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--sa-radius-sm);
    border: 1px solid var(--sa-border);
    background: #fff;
    color: var(--sa-text);
    font-size: 0.77rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sa-portal .sa-logout-btn:hover {
    background: rgba(192,87,92,0.08);
    border-color: #e6b8ba;
    color: #c0575c;
}

/* ---------- Topbar (user portal only) ---------- */
.sa-portal .topbar {
    border-radius: var(--sa-radius);
    box-shadow: var(--sa-shadow-sm);
    border: 1px solid var(--sa-border);
    padding: 0.6rem 0.95rem;
    margin-bottom: 1.1rem;
    font-size: 0.82rem;
}

/* ---------- Card ---------- */
.sa-portal .card-custom {
    border-radius: var(--sa-radius);
    border: 1px solid var(--sa-border);
    box-shadow: var(--sa-shadow-sm);
    padding: var(--sa-pad);
    margin-bottom: 1rem;
}

/* ---------- Buttons ---------- */
.sa-portal .btn { border-radius: var(--sa-radius-sm); font-size: 0.77rem; font-weight: 600; padding: 0.45rem 0.9rem; }
.sa-portal .btn-primary-custom { background: var(--sa-primary); border-color: var(--sa-primary); }
.sa-portal .btn-primary-custom:hover { background: var(--sa-primary-dark); border-color: var(--sa-primary-dark); }
.sa-portal .btn-outline-secondary { border-color: var(--sa-border); color: var(--sa-muted); }
.sa-portal .btn-outline-secondary:hover { background: var(--sa-bg-2); color: var(--sa-text); }
.sa-portal .btn-sm { padding: 0.32rem 0.7rem; font-size: 0.73rem; }

/* ---------- Form controls ---------- */
.sa-portal .form-label {
    font-size: 0.7rem;
    color: var(--sa-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.28rem;
    display: block;
}
.sa-portal .form-control, .sa-portal .form-select {
    border-radius: var(--sa-radius-sm);
    border-color: var(--sa-border);
    background: #fbfdfc;
    font-size: 0.81rem;
    padding: 0.45rem 0.7rem;
}
.sa-portal .form-control:focus, .sa-portal .form-select:focus {
    border-color: var(--sa-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(47,157,111,0.13);
}

/* ---------- Base table ---------- */
.sa-portal .table-custom { width: 100%; }
.sa-portal .table-custom thead th {
    background: var(--sa-primary-soft);
    color: var(--sa-primary-dark);
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    border-bottom: none;
    padding: 0.6rem 0.85rem;
}
.sa-portal .table-custom td { font-size: 0.79rem; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--sa-border); vertical-align: middle; }
.sa-portal .table-custom tbody tr:hover { background: #fafcfb; }
.sa-portal .sa-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    margin-right: 0.5rem;
}
.sa-portal .badge-active, .sa-portal .badge-inactive { border-radius: 20px; padding: 0.25rem 0.6rem; font-size: 0.66rem; }

/* ---------- Pagination ---------- */
.sa-portal .pagination { margin-top: 0.4rem; }
.sa-portal .pagination .page-link {
    border-radius: var(--sa-radius-sm);
    margin: 0 2px;
    font-size: 0.76rem;
    color: var(--sa-primary-dark);
    border-color: var(--sa-border);
}
.sa-portal .pagination .active .page-link { background: var(--sa-primary); border-color: var(--sa-primary); }

/* ---------- Alerts ---------- */
.sa-portal .alert-custom { border-radius: var(--sa-radius-sm); font-size: 0.78rem; padding: 0.6rem 0.85rem; }

.sa-portal .sa-input-textarea { align-items: flex-start; }
.sa-portal .sa-input-textarea > .lead-icon { top: 0.75rem; }
.sa-portal textarea.sa-control { padding-top: 0.6rem; resize: vertical; min-height: 60px; }

@media (max-width: 992px) {
    html:has(body.sa-portal),
    body.sa-portal {
        overflow: auto;   /* below 992px, page scrolls normally as one unit */
        height: auto;
    }
    .sa-portal .app-wrapper {
        flex-direction: column;
        height: auto;
    }
    .sa-portal .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--sa-border);
        height: auto;
        overflow: visible;
    }
    .sa-portal .main-content {
        height: auto;
        overflow: visible;
        padding: 1rem 1rem 1.6rem;
    }
}

/* nav link ek hi line me rahe, wrap na ho */
.sa-portal .sidebar a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;        /* text kabhi wrap na kare */
    min-width: 0;
}
/* icon fix width, text baaki jagah le, badge end me */
.sa-portal .sidebar a > i:first-child { flex-shrink: 0; }

/* Sidebar pending badge — chhota circle */
.sa-portal .sidebar a .sa-nav-badge {
    margin-left: auto;
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    color: #fff;
    background: #e5484d;
    box-shadow: 0 0 0 2px rgba(229,72,77,0.15);
}
.sa-portal .sidebar a.active .sa-nav-badge {
    background: #fff;
    color: #227a54;
    box-shadow: none;
}

/* ============================================================
   GLOBAL ENHANCED SCROLLBAR — light green, applies everywhere
   inside the superadmin portal: page body, modals, tables,
   textareas, sidebars, dropdowns — anything that scrolls.
   ============================================================ */
html:has(body.sa-portal),
.sa-portal,
.sa-portal * {
    scrollbar-width: thin;
    scrollbar-color: var(--sa-primary-soft) var(--sa-bg-2);
}

html:has(body.sa-portal)::-webkit-scrollbar,
.sa-portal ::-webkit-scrollbar,
.sa-portal::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
.sa-portal ::-webkit-scrollbar-track,
.sa-portal::-webkit-scrollbar-track {
    background: var(--sa-bg-2);
    border-radius: 20px;
}
.sa-portal ::-webkit-scrollbar-thumb,
.sa-portal::-webkit-scrollbar-thumb {
    background: var(--sa-primary-soft);
    border-radius: 20px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.sa-portal ::-webkit-scrollbar-thumb:hover,
.sa-portal::-webkit-scrollbar-thumb:hover {
    background: var(--sa-primary);
    background-clip: padding-box;
}
.sa-portal ::-webkit-scrollbar-corner {
    background: transparent;
}