/* ==========================================================================
   Super Admin — premium shell & component styles.
   Scoped to this app only (separate baseURL/public root from admin/manager/
   employee). Selectors are still prefixed with `sa-` for hygiene.
   ========================================================================== */

:root {
    --sa-bg: #f4f6f9;
    --sa-surface: #ffffff;
    --sa-border: #e7e9ee;
    --sa-text: #1f2430;
    --sa-text-muted: #6b7280;
    --sa-primary: #2b64f5;
    --sa-primary-dark: #1b2230;
    --sa-radius: 10px;
    --sa-radius-sm: 7px;
    --sa-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --sa-sidebar-w: 240px;
}

body {
    background: var(--sa-bg);
    color: var(--sa-text);
    font-size: .925rem;
}

/* ---------- Sidebar ---------- */
.sa-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sa-sidebar-w);
    background: var(--sa-primary-dark);
    color: #cfd5e2;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .2s ease;
}
.sa-sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px; font-weight: 700; color: #fff; font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sa-sidebar .brand i { color: var(--sa-primary); font-size: 1.15rem; }
.sa-sidebar .brand small { display: block; font-weight: 400; font-size: .7rem; color: #8b93a7; }
.sa-sidebar nav { padding: 10px 12px; }
.sa-sidebar a.sa-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin-bottom: 2px;
    color: #cfd5e2; text-decoration: none; font-size: .87rem;
    border-radius: var(--sa-radius-sm);
}
.sa-sidebar a.sa-nav-link i { width: 16px; text-align: center; color: #8b93a7; font-size: .85rem; }
.sa-sidebar a.sa-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sa-sidebar a.sa-nav-link:hover i { color: #fff; }
.sa-sidebar a.sa-nav-link.active { background: var(--sa-primary); color: #fff; font-weight: 600; }
.sa-sidebar a.sa-nav-link.active i { color: #fff; }
.sa-sidebar .sa-nav-divider { border-top: 1px solid rgba(255,255,255,.08); margin: 10px 4px; }
.sa-sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1020;
}

/* ---------- Topbar ---------- */
.sa-content { margin-left: var(--sa-sidebar-w); padding: 18px 26px 50px; min-height: 100vh; }
.sa-topbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 10px 4px; margin-bottom: 4px;
}
.sa-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sa-sidebar-toggle {
    display: none; border: 1px solid var(--sa-border); background: #fff;
    border-radius: var(--sa-radius-sm); width: 34px; height: 34px; align-items: center; justify-content: center;
    color: var(--sa-text-muted); flex: none;
}
.sa-breadcrumb { font-size: .78rem; color: var(--sa-text-muted); margin-bottom: 2px; }
.sa-breadcrumb a { color: var(--sa-text-muted); text-decoration: none; }
.sa-breadcrumb a:hover { color: var(--sa-primary); }
.sa-page-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sa-page-title h4 { margin: 0; font-weight: 700; font-size: 1.2rem; }
.sa-page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }

.sa-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--sa-primary); color: #fff; display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: .8rem; flex: none;
}
.sa-user-menu { border: 1px solid var(--sa-border); background: #fff; border-radius: 999px; padding: 4px 10px 4px 4px; }
.sa-user-menu:hover { background: #f8f9fb; }

/* ---------- Cards & tables ---------- */
.sa-card { background: var(--sa-surface); border: 1px solid var(--sa-border); border-radius: var(--sa-radius); box-shadow: var(--sa-shadow); }
.sa-card-header { padding: 14px 18px; border-bottom: 1px solid var(--sa-border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sa-card-header h6 { margin: 0; font-weight: 700; }
.sa-card-body { padding: 18px; }

.sa-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1200px) { .sa-stat-grid { grid-template-columns: repeat(2, 1fr); } }
.sa-stat {
    background: var(--sa-surface); border: 1px solid var(--sa-border); border-radius: var(--sa-radius);
    box-shadow: var(--sa-shadow); padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.sa-stat-icon {
    width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    font-size: .95rem; flex: none;
}
.sa-stat-body { min-width: 0; }
.sa-stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--sa-text-muted); font-weight: 600; }
.sa-stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.sa-stat-sub { font-size: .74rem; color: var(--sa-text-muted); }

.sa-stat-icon.bg-success-subtle { background: #e7f6ec; color: #16a34a; }
.sa-stat-icon.bg-primary-subtle { background: #e8edfe; color: #2b64f5; }
.sa-stat-icon.bg-warning-subtle { background: #fef3e2; color: #d97706; }
.sa-stat-icon.bg-secondary-subtle { background: #eef0f3; color: #6b7280; }
.sa-stat-icon.bg-danger-subtle { background: #fdecec; color: #dc2626; }
.sa-stat-icon.bg-info-subtle { background: #e6f4fb; color: #0891b2; }

.table-responsive.sa-table-wrap { border-radius: var(--sa-radius); }
table.sa-table { margin-bottom: 0; }
table.sa-table thead th {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; color: var(--sa-text-muted);
    border-top: none; border-bottom: 1px solid var(--sa-border); background: #fafbfc;
    font-weight: 700; white-space: nowrap; padding: 10px 14px;
}
table.sa-table td { padding: 11px 14px; vertical-align: middle; border-bottom: 1px solid #f0f1f4; }
table.sa-table tbody tr:hover { background: #f8f9fc; }
table.sa-table tbody tr:last-child td { border-bottom: none; }
.sa-cell-title { font-weight: 600; color: var(--sa-text); text-decoration: none; }
.sa-cell-title:hover { color: var(--sa-primary); }
.sa-cell-sub { font-size: .76rem; color: var(--sa-text-muted); }
.sa-cell-mono { font-family: SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }

/* ---------- Badges ---------- */
.badge.sa-badge { font-weight: 600; font-size: .72rem; padding: 5px 9px; border-radius: 6px; }
.sa-badge-active { background: #e7f6ec; color: #16803c; }
.sa-badge-trial { background: #e8edfe; color: #2b64f5; }
.sa-badge-suspended { background: #fef3e2; color: #b45309; }
.sa-badge-inactive { background: #eef0f3; color: #4b5563; }
.sa-badge-expired { background: #fdecec; color: #b91c1c; }
.sa-badge-cancelled { background: #f4f0fb; color: #6d28d9; }

.sa-action-badge { font-weight: 600; font-size: .68rem; padding: 4px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .02em; }
.sa-action-auth { background: #eef0f3; color: #4b5563; }
.sa-action-company { background: #e8edfe; color: #2b64f5; }
.sa-action-plan { background: #f4f0fb; color: #6d28d9; }
.sa-action-subscription { background: #e6f4fb; color: #0e7490; }
.sa-action-impersonation { background: #fef3e2; color: #b45309; }
.sa-action-security { background: #fdecec; color: #b91c1c; }
.sa-action-default { background: #eef0f3; color: #4b5563; }

/* ---------- Actions / one-row action groups ---------- */
.sa-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; flex-wrap: nowrap; justify-content: flex-end; }
.sa-actions .btn { white-space: nowrap; }
.sa-actions .dropdown-menu { font-size: .85rem; }
.sa-actions .dropdown-menu .text-danger:hover { background: #fdecec; }

/* ---------- Filter bar ---------- */
.sa-filter-bar { background: var(--sa-surface); border: 1px solid var(--sa-border); border-radius: var(--sa-radius); box-shadow: var(--sa-shadow); padding: 14px 16px; margin-bottom: 16px; }
.sa-filter-bar .form-label { font-size: .72rem; text-transform: uppercase; color: var(--sa-text-muted); font-weight: 600; margin-bottom: 4px; }
.sa-filter-bar .form-control, .sa-filter-bar .form-select { font-size: .85rem; }

/* ---------- Pagination ---------- */
.sa-pagination-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--sa-border); font-size: .82rem; color: var(--sa-text-muted); }
.sa-pagination-bar .pagination { margin: 0; }
.sa-pagination-bar .page-link { font-size: .82rem; }
.sa-per-page-select { width: auto; display: inline-block; font-size: .82rem; padding: 3px 26px 3px 8px; }

/* ---------- Empty states ---------- */
.sa-empty { text-align: center; padding: 46px 20px; color: var(--sa-text-muted); }
.sa-empty i { font-size: 1.9rem; color: #c7cbd4; margin-bottom: 10px; display: block; }
.sa-empty p { margin-bottom: 14px; }

/* ---------- Forms ---------- */
.sa-form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--sa-text-muted); font-weight: 700; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--sa-border); }
.sa-required { color: #dc2626; }
.sa-field-hint { font-size: .76rem; color: var(--sa-text-muted); }
.sa-password-wrap { position: relative; }
.sa-password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--sa-text-muted); padding: 4px; }
.sa-readonly-field { background: #fafbfc; }

/* ---------- Usage / progress ---------- */
.sa-usage-item { text-align: center; }
.sa-usage-value { font-size: 1.15rem; font-weight: 700; }
.sa-usage-label { font-size: .74rem; color: var(--sa-text-muted); margin-bottom: 6px; }
.sa-usage-bar { height: 6px; border-radius: 4px; background: #eef0f3; overflow: hidden; margin-top: 6px; }
.sa-usage-bar-fill { height: 100%; background: var(--sa-primary); }
.sa-usage-bar-fill.sa-usage-over { background: #dc2626; }

/* ---------- Feature toggle list ---------- */
.sa-feature-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border: 1px solid var(--sa-border); border-radius: var(--sa-radius-sm); margin-bottom: 6px; }
.sa-feature-row .form-check-input { width: 2.4em; height: 1.3em; }

/* ---------- Toasts ---------- */
.sa-toast-container { position: fixed; top: 16px; right: 16px; z-index: 1080; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Detail header (Company Details) ---------- */
.sa-detail-header { background: var(--sa-surface); border: 1px solid var(--sa-border); border-radius: var(--sa-radius); box-shadow: var(--sa-shadow); padding: 18px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.sa-detail-header h4 { margin: 0 0 4px; font-weight: 700; }
.sa-detail-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--sa-text-muted); font-size: .85rem; }
.sa-kv-table th { width: 170px; font-weight: 600; color: var(--sa-text-muted); font-size: .82rem; border-top: none; }
.sa-kv-table td { border-top: none; font-size: .87rem; }

/* ---------- Login ---------- */
.sa-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #1b2230 0%, #232c40 100%); }
.sa-login-card { width: 400px; background: #fff; border-radius: 14px; padding: 34px 32px; box-shadow: 0 20px 45px rgba(0,0,0,.25); }
.sa-login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.sa-login-brand .sa-login-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--sa-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.sa-login-card h1 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.sa-login-card p.sub { color: var(--sa-text-muted); font-size: .84rem; margin: 2px 0 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .sa-sidebar { transform: translateX(-100%); }
    .sa-sidebar.sa-sidebar-open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,0); }
    .sa-sidebar-open + .sa-sidebar-backdrop,
    .sa-sidebar-backdrop.show { display: block; }
    .sa-content { margin-left: 0; padding: 14px 16px 40px; }
    .sa-sidebar-toggle { display: inline-flex; }
    .sa-stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 576px) {
    .sa-stat-grid { grid-template-columns: 1fr; }
    .sa-page-actions { flex-wrap: wrap; }
}
