/* ================================================================
   Coreva Platform - Admin Area Styles
   Brand Identity: Controlled Stability (Direction A - Pure Authority)
   Design System v2 — Dark sidebar, Coreva icon pack, elevation polish
   ================================================================ */

:root {
    /* ── Core Brand Palette ───────────────────────────────────────── */
    --color-primary:            #0F172A;   /* Deep Navy  */
    --color-secondary:          #334155;   /* Slate Gray */
    --color-base:               #FFFFFF;
    --color-accent:             #14B8A6;   /* Teal CTA   */
    --color-icon-stroke:        #2FB7EC;   /* Coreva icon cyan */

    /* ── Text Tokens ─────────────────────────────────────────────── */
    --color-text-primary:       #0F172A;
    --color-text-secondary:     #334155;
    --color-text-light:         #94a3b8;

    /* ── Border / Surface ─────────────────────────────────────────── */
    --color-border:             #e2e8f0;
    --color-surface:            #f8fafc;   /* light page surface */

    /* ── Sidebar — DARK theme ─────────────────────────────────────── */
    --color-sidebar-bg:         #0F172A;   /* Deep Navy sidebar */
    --color-sidebar-border:     rgba(255,255,255,0.07);
    --color-sidebar-hover:      rgba(255,255,255,0.07);
    --color-sidebar-active-bg:  rgba(47,183,236,0.12);  /* icon-cyan tint */
    --color-sidebar-active-bar: #2FB7EC;   /* cyan left indicator */
    --color-sidebar-text:       rgba(255,255,255,0.78);
    --color-sidebar-text-muted: rgba(255,255,255,0.40);
    --color-sidebar-heading:    rgba(255,255,255,0.35);

    /* ── Elevation / Shadow Scale ─────────────────────────────────── */
    --shadow-xs:  0 1px  3px rgba(15,23,42,0.06);
    --shadow-sm:  0 2px  8px rgba(15,23,42,0.08);
    --shadow-md:  0 4px 16px rgba(15,23,42,0.10);
    --shadow-lg:  0 8px 32px rgba(15,23,42,0.14);

    /* ── Border Radius Scale ──────────────────────────────────────── */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* ── Gradient Accents ─────────────────────────────────────────── */
    --gradient-accent:   linear-gradient(135deg, #2FB7EC 0%, #14B8A6 100%);
    --gradient-accent-h: linear-gradient(90deg,  #2FB7EC 0%, #14B8A6 100%);

    /* ── Typography Scale ─────────────────────────────────────────── */
    --font-family-base:  'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --text-xs:   0.75rem;   /* 12px */
    --text-sm:   0.875rem;  /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg:   1.125rem;  /* 18px */
    --text-xl:   1.25rem;   /* 20px */
    --text-2xl:  1.5rem;    /* 24px */
    --text-3xl:  1.875rem;  /* 30px */
}

/* ================================================================
   Admin Layout
   ================================================================ */

/* Ensure body uses full viewport height with flexbox */
html {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
}

/* Navbar - Fixed at top */
.navbar-coreva {
    flex-shrink: 0;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--color-primary) !important;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
}

/* Logo - Direction A: Pure Authority (Text-Only Wordmark) */
.coreva-logo {
    height: 24px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

.coreva-logo-sm {
    height: 18px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

/* Content area wrapper - fills space between navbar and footer */
.flex-fill {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Admin wrapper - fills the flex-fill column; height is flex-driven, not hardcoded */
.admin-wrapper {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar - dark navy surface */
.admin-sidebar {
    width: 250px;
    flex-shrink: 0;
    background-color: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-sidebar-border);
    padding: 1.5rem 0;
    overflow-y: auto;
}

/* Content - scrollable, fills remaining space */
.admin-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    background-color: var(--color-surface);
}

/* Custom scrollbar styling for content area */
.admin-content::-webkit-scrollbar {
    width: 8px;
}

.admin-content::-webkit-scrollbar-track {
    background: var(--color-sidebar-bg);
}

.admin-content::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: 4px;
}

.admin-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Firefox scrollbar styling */
.admin-content {
    scrollbar-width: thin;
    scrollbar-color: var(--color-secondary) var(--color-sidebar-bg);
}

/* Footer - fixed at bottom, never scrolls */
.footer-fixed {
    flex-shrink: 0 !important;
    position: sticky;
    bottom: 0;
    z-index: 999;
    width: 100%;
}

/* Apply brand colours when footer-coreva is also present */
.footer-coreva {
    background-color: var(--color-primary);
    color: rgba(255,255,255,0.85);
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ================================================================
   Admin Sidebar - DARK Navy Theme (Coreva Design System v2)
   ================================================================ */

.sidebar-heading {
    color: var(--color-sidebar-heading);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-item {
    margin-bottom: 0.125rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.6875rem 1.25rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-right: 0.75rem;
}

.sidebar-nav-link:hover {
    background-color: var(--color-sidebar-hover);
    color: #ffffff;
}

.sidebar-nav-link.active {
    background-color: var(--color-sidebar-active-bg);
    color: #2FB7EC;
    border-left-color: var(--color-sidebar-active-bar);
    font-weight: 600;
}

/* Icon alignment inside nav links */
.sidebar-nav-link img.ci,
.sidebar-nav-link .ci {
    margin-right: 0.75rem;
    flex-shrink: 0;
}

/* Active icon — full brightness cyan */
.sidebar-nav-link.active img.ci { opacity: 1; }
.sidebar-nav-link:not(.active) img.ci { opacity: 0.55; filter: brightness(0) invert(1); }
.sidebar-nav-link:hover img.ci { opacity: 0.85; filter: brightness(0) invert(1); }

/* ================================================================
   Admin Content Area
   ================================================================ */

.admin-content {
    flex: 1;
    padding: 2rem;
    background-color: var(--color-base);
    overflow-y: auto; /* Content scrolls, not the whole page */
}

.admin-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.admin-title {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.admin-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

/* ================================================================
   Cards & Tables
   ================================================================ */

.admin-card {
    background-color: var(--color-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}

/* Subtle cyan gradient accent line at top of card */
.admin-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient-accent-h);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.admin-card:hover::before { opacity: 1; }
.admin-card:hover { box-shadow: var(--shadow-sm); }

.admin-card-title {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.table-coreva {
    border-collapse: separate;
    border-spacing: 0;
}

.table-coreva thead th {
    background-color: var(--color-sidebar-bg);
    color: var(--color-text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
    padding: 0.75rem 1rem;
}

.table-coreva tbody tr {
    transition: background-color 0.2s ease;
}

.table-coreva tbody tr:hover {
    background-color: var(--color-sidebar-bg);
}

.table-coreva tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

/* ================================================================
   Stats Cards
   ================================================================ */

.stat-card {
    background-color: var(--color-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xs);
}

.stat-card:hover {
    border-color: #2FB7EC;
    box-shadow: var(--shadow-md);
}

.stat-label {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.5rem;
}

.stat-value {
    color: var(--color-primary);
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
    line-height: 1;
}

.stat-change {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 44px;
    height: 44px;
    background: var(--gradient-accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(47, 183, 236, 0.30);
}

/* ================================================================
   Buttons - Consistent with Public
   ================================================================ */

.btn-coreva-primary {
    background: var(--gradient-accent);
    border: none;
    color: var(--color-base);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 6px rgba(20, 184, 166, 0.30);
}

.btn-coreva-primary:hover {
    opacity: 0.92;
    color: var(--color-base);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.40);
}

.btn-coreva-secondary {
    background-color: transparent;
    border: 2px solid var(--color-secondary);
    color: var(--color-secondary);
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-coreva-secondary:hover {
    background-color: var(--color-secondary);
    border-color: var(--color-secondary);
    color: var(--color-base);
}

.btn-coreva-danger {
    background-color: transparent;
    border: 2px solid #dc2626;
    color: #dc2626;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-coreva-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
    color: var(--color-base);
}

/* ================================================================
   Badges
   ================================================================ */

.badge-coreva {
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 0.25rem;
}

.badge-coreva-primary {
    background-color: var(--color-accent);
    color: var(--color-base);
}

.badge-coreva-secondary {
    background-color: var(--color-sidebar-bg);
    color: var(--color-text-primary);
}

.badge-coreva-success {
    background-color: #10b981;
    color: var(--color-base);
}

.badge-coreva-warning {
    background-color: #f59e0b;
    color: var(--color-base);
}

.badge-coreva-danger {
    background-color: #dc2626;
    color: var(--color-base);
}

/* ================================================================
   Responsive Adjustments
   ================================================================ */

/* Prevent horizontal scrolling */
.admin-content > * {
    max-width: 100%;
}

/* Ensure dashboard cards don't overflow */
.row.g-4 {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.row.g-4 > * {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Make tables responsive */
.table-responsive {
    max-width: 100%;
    overflow-x: auto;
}

@media (max-width: 768px) {
    .admin-wrapper {
        height: auto;
        min-height: 0;
    }

    .admin-sidebar {
        position: fixed;
        left: -250px;
        z-index: 1000;
        transition: left 0.3s ease;
        height: calc(100vh - 64px);
    }
    
    .admin-sidebar.show {
        left: 0;
    }
    
    .admin-content {
        padding: 1rem;
        width: 100%;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .admin-header {
        margin-bottom: 1.5rem;
    }
}
/* ================================================================
   Platform Icon - Structural Foundation Symbol
   ================================================================ */

.platform-icon {
    height: 32px;
    width: 32px;
    display: inline-block;
    vertical-align: middle;
}

.platform-icon-sm {
    height: 24px;
    width: 24px;
    display: inline-block;
    vertical-align: middle;
}

.platform-icon-xs {
    height: 16px;
    width: 16px;
    display: inline-block;
    vertical-align: middle;
}

.platform-icon-lg {
    height: 48px;
    width: 48px;
    display: inline-block;
    vertical-align: middle;
}

.platform-icon-xl {
    height: 64px;
    width: 64px;
    display: inline-block;
    vertical-align: middle;
}

/* ================================================================
   Tenant Area � Sidebar & Layout
   Mirrors the admin layout structure; uses the same sidebar
   utility classes (.sidebar-heading, .sidebar-nav-*, etc.)
   ================================================================ */

/* Tenant wrapper - fills the flex-fill column; height is flex-driven, not hardcoded */
.tenant-wrapper {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar - same dimensions & colours as admin */
.tenant-sidebar {
    width: 240px;
    flex-shrink: 0;
    background-color: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem 0 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling matches admin */
.tenant-sidebar::-webkit-scrollbar { width: 4px; }
.tenant-sidebar::-webkit-scrollbar-track { background: transparent; }
.tenant-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

/* Content area */
.tenant-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--color-base);
    scrollbar-width: thin;
    scrollbar-color: var(--color-secondary) var(--color-sidebar-bg);
}

.tenant-content::-webkit-scrollbar { width: 8px; }
.tenant-content::-webkit-scrollbar-track { background: var(--color-sidebar-bg); }
.tenant-content::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: 4px;
}
.tenant-content::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

/* -- Sidebar footer: logged-in user info -- */
.sidebar-footer {
    margin-top: auto;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--color-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-user-email {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 148px;
    display: block;
}

.sidebar-user-role {
    margin-top: 0.125rem;
}

/* ----------------------------------------------------------------
   Tenant context badge — shown in admin area when viewing a tenant
   ---------------------------------------------------------------- */
.tenant-context-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    background-color: #E6F1FB;
    color: #0C447C;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 0.5px solid #185FA5;
    white-space: nowrap;
    flex-shrink: 0;
}

/* -- Mobile sidebar toggle button -- */
.sidebar-mobile-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    padding: 0.4rem 0.75rem;
    margin: 0.75rem 1rem 0;
    color: var(--color-text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.sidebar-mobile-toggle:hover {
    background-color: var(--color-sidebar-hover);
}

/* -- Mobile overlay -- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* -- Responsive -- */
@media (max-width: 991.98px) {
    .tenant-wrapper {
        height: auto;
        min-height: 0;
    }

    .tenant-sidebar {
        position: fixed;
        left: -240px;
        top: 64px;
        height: calc(100vh - 64px);
        z-index: 999;
        transition: left 0.25s ease;
        box-shadow: none;
    }

    .tenant-sidebar.sidebar-open {
        left: 0;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
    }

    .tenant-content {
        width: 100%;
        height: auto;
        overflow-y: visible;
    }
}



/* ================================================================
   DESIGN SYSTEM UPDATE — Sprint 4
   All additions append after existing rules.
   ================================================================ */

/* ----------------------------------------------------------------
   Badge system — corrected colour ramps (design system values)
   Overrides the existing .badge-coreva-* definitions above.
   ---------------------------------------------------------------- */
.badge-coreva {
    display: inline-block;
    padding: 0.28rem 0.65rem;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-coreva-success {
    background-color: #E1F5EE;
    color: #085041;
}

.badge-coreva-primary {
    background-color: #E6F1FB;
    color: #0C447C;
}

.badge-coreva-warning {
    background-color: #FAEEDA;
    color: #633806;
}

.badge-coreva-danger {
    background-color: #FCEBEB;
    color: #A32D2D;
}

.badge-coreva-secondary {
    background-color: #F1EFE8;
    color: #444441;
}


/* ----------------------------------------------------------------
   Tenant page header — full-width, consistent with admin area
   ---------------------------------------------------------------- */
.tenant-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.tenant-page-title {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1.75rem;
    margin: 0 0 0.25rem 0;
}

.tenant-page-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tenant-role-pill {
    display: inline-block;
    background-color: var(--color-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ----------------------------------------------------------------
   Coreva alert — replaces Bootstrap alert in tenant area
   ---------------------------------------------------------------- */
.coreva-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    border: 0.5px solid;
    font-size: 0.875rem;
    line-height: 1.5;
}

.coreva-alert-danger {
    background-color: #FCEBEB;
    border-color: #A32D2D;
    color: #791F1F;
}

.coreva-alert-warning {
    background-color: #FAEEDA;
    border-color: #854F0B;
    color: #633806;
}

.coreva-alert-success {
    background-color: #EAF3DE;
    border-color: #3B6D11;
    color: #27500A;
}

.coreva-alert-info {
    background-color: #E6F1FB;
    border-color: #185FA5;
    color: #0C447C;
}


/* ----------------------------------------------------------------
   Product card — tenant dashboard product launcher
   ---------------------------------------------------------------- */
.product-card {
    background-color: var(--color-base);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s ease;
}

.product-card:hover {
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.product-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.product-card-name {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1rem;
    margin: 0 0 0.2rem 0;
}

.product-card-code {
    font-size: 11px;
    color: var(--color-text-secondary);
    font-family: monospace;
    background: var(--color-sidebar-bg);
    padding: 1px 5px;
    border-radius: 3px;
    border: 0.5px solid var(--color-border);
}

.product-card-desc {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    line-height: 1.55;
    flex-grow: 1;
    margin: 0 0 1rem 0;
}

.product-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    padding: 0.75rem 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

.product-card-footer {
    margin-top: auto;
}

.product-card-cta-hint {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    margin: 0.5rem 0 0 0;
    text-align: center;
}


/* ----------------------------------------------------------------
   Skeleton loading states
   ---------------------------------------------------------------- */
.skel {
    background: linear-gradient(
        90deg,
        var(--color-sidebar-bg) 25%,
        var(--color-border) 50%,
        var(--color-sidebar-bg) 75%
    );
    background-size: 200% 100%;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skel-text {
    height: 14px;
    margin-bottom: 8px;
}

.skel-text-sm {
    height: 11px;
    margin-bottom: 6px;
}

.skel-heading {
    height: 24px;
    margin-bottom: 12px;
}

.skel-card {
    height: 120px;
    border-radius: 0.5rem;
}

.skel-metric {
    height: 72px;
    border-radius: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .skel { animation: none; }
}

/* ----------------------------------------------------------------
   Toast notification component
   ---------------------------------------------------------------- */
.toast-container-coreva {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
    pointer-events: none;
}

.toast-coreva {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    border: 0.5px solid;
    font-size: 0.875rem;
    line-height: 1.5;
    pointer-events: all;
    animation: toast-in 0.2s ease;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.toast-coreva-success {
    background: #EAF3DE;
    border-color: #3B6D11;
    color: #27500A;
}

.toast-coreva-warning {
    background: #FAEEDA;
    border-color: #854F0B;
    color: #633806;
}

.toast-coreva-error {
    background: #FCEBEB;
    border-color: #A32D2D;
    color: #791F1F;
}

.toast-coreva-info {
    background: #E6F1FB;
    border-color: #185FA5;
    color: #0C447C;
}

.toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}


/* ----------------------------------------------------------------
   Session expiry warning modal — Sprint 2
   ---------------------------------------------------------------- */
.session-expiry-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.session-expiry-backdrop.active {
    display: flex;
}

.session-expiry-modal {
    background: var(--color-base);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 400px;
    width: calc(100% - 2rem);
    border: 0.5px solid var(--color-border);
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
    text-align: center;
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.session-expiry-icon {
    width: 48px;
    height: 48px;
    background: #FAEEDA;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: #854F0B;
}

.session-expiry-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
    margin: 0 0 0.5rem 0;
}

.session-expiry-body {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0 0 1.5rem 0;
    line-height: 1.55;
}

.session-expiry-countdown {
    font-size: 2rem;
    font-weight: 600;
    color: #854F0B;
    margin: 0.5rem 0 1.25rem;
    font-variant-numeric: tabular-nums;
}

.session-expiry-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* ----------------------------------------------------------------
   Rate-limit feedback — Sprint 2
   ---------------------------------------------------------------- */
.rate-limit-alert {
    background: #FAEEDA;
    border: 0.5px solid #854F0B;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #633806;
    margin-bottom: 1.25rem;
}

.rate-limit-timer {
    font-weight: 600;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    color: #854F0B;
    min-width: 2.5rem;
    display: inline-block;
}

/* ----------------------------------------------------------------
   Sidebar sub-item styling (Onboard clinic link)
   ---------------------------------------------------------------- */
.sidebar-nav-link--sub {
    padding-left: 2.25rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.sidebar-nav-link--sub.active {
    color: var(--color-accent);
}

.sidebar-nav-link--sub:hover {
    color: var(--color-primary);
}


/* ----------------------------------------------------------------
   Responsive strategy — Sprint 4
   Desktop ≥1024px: full sidebar layout (existing behaviour)
   Tablet 768–1023px: sidebar collapses, table loses secondary cols
   Mobile <768px: single column, table → card list
   ---------------------------------------------------------------- */

/* Tablet: hide less important table columns */
@media (max-width: 1023px) {
    .table-coreva .col-hide-tablet,
    .demo-table .col-hide-tablet {
        display: none;
    }

    .admin-content {
        padding: 1.25rem;
    }

    .admin-header {
        margin-bottom: 1.25rem;
    }

    .product-card-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Mobile: single-column, table becomes card list */
@media (max-width: 767px) {
    .admin-title {
        font-size: 1.35rem;
    }

    .admin-content {
        padding: 1rem;
    }

    /* Hide all non-essential table columns on mobile */
    .table-coreva .col-hide-mobile,
    .table-coreva th:not(:first-child):not(:last-child),
    .table-coreva td:not(:first-child):not(:last-child) {
        display: none;
    }

    /* Product cards stack to single column on mobile */
    .product-card {
        border-radius: 0.5rem;
    }

    /* Metric cards: 2-column grid on mobile */
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Toast repositioned on mobile */
    .toast-container-coreva {
        top: auto;
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: 100%;
    }

    /* Session expiry modal full width on mobile */
    .session-expiry-modal {
        margin: 1rem;
        padding: 1.5rem;
    }

    /* Tenant page header stacks on mobile */
    .tenant-page-header {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ----------------------------------------------------------------
   Admin sidebar responsive (≤991px already handled above —
   these rules fix admin-wrapper height on small screens)
   ---------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .admin-wrapper {
        height: auto;
        min-height: 0;
        flex-direction: row;
    }

    .admin-sidebar {
        position: fixed;
        left: -250px;
        top: 64px;
        height: calc(100vh - 64px);
        z-index: 999;
        transition: left 0.25s ease;
    }

    .admin-sidebar.sidebar-open {
        left: 0;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
    }

    .admin-content {
        width: 100%;
        height: auto;
        overflow-y: visible;
    }
}



/* ================================================================
   Metrics grid — dashboard stat cards layout
   ================================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--color-sidebar-bg);
    border: 0.5px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
}

.metric-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 0.35rem;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-primary);
    line-height: 1.1;
}

/* ================================================================
   Table column visibility utilities
   ================================================================ */

/* Hide less important columns on tablet */
@media (max-width: 1023px) {
    .col-hide-tablet { display: none !important; }
}

/* Hide secondary columns on mobile — only show Name/Title + Status + Actions */
@media (max-width: 767px) {
    .col-hide-mobile  { display: none !important; }
}

/* ================================================================
   Text utility classes used in tenant/admin areas
   ================================================================ */
.text-primary-coreva   { color: var(--color-text-primary); }
.text-secondary-coreva { color: var(--color-text-secondary); }

/* ================================================================
   Btn-sm size adjustment for admin secondary actions
   ================================================================ */
.btn-coreva-primary.btn-sm,
.btn-coreva-secondary.btn-sm,
.btn-coreva-danger.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8125rem;
}

/* ================================================================
   Tenant portal — admin-card used for full-width content sections
   (tenant dashboard no longer uses Bootstrap .container)
   ================================================================ */
.tenant-content .admin-card {
    margin-bottom: 1.25rem;
}

/* ================================================================
   Admin header — flex variant with right-side actions
   ================================================================ */
.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

/* ================================================================
   Badge — icon-secondary utility for empty state icons
   ================================================================ */
.icon-secondary {
    color: var(--color-text-secondary);
}


/* ================================================================
   DESIGN SYSTEM v2 — Appended upgrades
   Dark sidebar parity: tenant-sidebar mirrors admin-sidebar
   ================================================================ */

/* Tenant sidebar — dark navy to match admin */
.tenant-sidebar {
    background-color: var(--color-sidebar-bg) !important;
    border-right: 1px solid var(--color-sidebar-border) !important;
}

/* Sidebar heading on dark bg */
.tenant-sidebar .sidebar-heading {
    color: var(--color-sidebar-heading);
}

/* Sidebar nav links on dark bg */
.tenant-sidebar .sidebar-nav-link {
    color: var(--color-sidebar-text);
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-right: 0.75rem;
    font-size: var(--text-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tenant-sidebar .sidebar-nav-link:hover {
    background-color: var(--color-sidebar-hover);
    color: #ffffff;
}

.tenant-sidebar .sidebar-nav-link.active {
    background-color: var(--color-sidebar-active-bg);
    color: #2FB7EC;
    border-left-color: var(--color-sidebar-active-bar);
    font-weight: 600;
}

/* Icon opacity on dark sidebar */
.tenant-sidebar .sidebar-nav-link:not(.active) img.ci {
    opacity: 0.55;
    filter: brightness(0) invert(1);
}
.tenant-sidebar .sidebar-nav-link.active img.ci { opacity: 1; }
.tenant-sidebar .sidebar-nav-link:hover img.ci  { opacity: 0.85; filter: brightness(0) invert(1); }

/* Sidebar footer on dark bg */
.tenant-sidebar .sidebar-footer {
    border-top: 1px solid var(--color-sidebar-border);
}

.tenant-sidebar .sidebar-user-email {
    color: var(--color-sidebar-text);
}

/* Sidebar user avatar — gradient */
.sidebar-user-avatar {
    background: var(--gradient-accent) !important;
    box-shadow: 0 2px 8px rgba(47, 183, 236, 0.25);
}

/* Admin sidebar scrollbar on dark bg */
.admin-sidebar::-webkit-scrollbar        { width: 4px; }
.admin-sidebar::-webkit-scrollbar-track  { background: transparent; }
.admin-sidebar::-webkit-scrollbar-thumb  { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* Platform icon on dark sidebar — teal tint */
.admin-sidebar  .platform-icon-sm,
.tenant-sidebar .platform-icon-sm {
    filter: brightness(0) saturate(100%) invert(65%) sepia(78%) saturate(400%) hue-rotate(155deg);
}

/* ================================================================
   DESIGN SYSTEM v2 — Form input polish
   ================================================================ */

.form-control:focus,
.form-select:focus {
    border-color: var(--color-icon-stroke);
    box-shadow: 0 0 0 0.2rem rgba(47, 183, 236, 0.20);
}

/* ================================================================
   DESIGN SYSTEM v2 — Table upgrade
   ================================================================ */

.table-coreva thead th {
    background-color: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
}

.table-coreva tbody tr:hover {
    background-color: #f0f9ff;  /* ice-blue tint on hover */
}

/* ================================================================
   DESIGN SYSTEM v2 — Admin content background
   ================================================================ */

.admin-content,
.tenant-content {
    background-color: var(--color-surface);
}

/* ================================================================
   DESIGN SYSTEM v2 — Mobile sidebar toggle on dark sidebar
   ================================================================ */

.sidebar-mobile-toggle {
    background: var(--color-sidebar-bg);
    border: 1px solid var(--color-sidebar-border) !important;
    color: var(--color-sidebar-text) !important;
}

.sidebar-mobile-toggle:hover {
    background: var(--color-sidebar-hover) !important;
}


/* ================================================================
   RTL (Arabic) Layout Overrides
   Appended at end of admin.css to guarantee cascade wins.
   All rules scoped to [dir="rtl"] — zero LTR impact.
   ================================================================ */

/* Tenant wrapper: flip sidebar to right side */
[dir="rtl"] .tenant-wrapper {
    flex-direction: row-reverse;
}

[dir="rtl"] .tenant-sidebar {
    border-right: none !important;
    border-left: 1px solid var(--color-border) !important;
}

/* Admin wrapper: flip sidebar to right side */
[dir="rtl"] .admin-wrapper {
    flex-direction: row-reverse;
}

[dir="rtl"] .admin-sidebar {
    border-right: none !important;
    border-left: 1px solid var(--color-sidebar-border) !important;
}

/* Active bar: flip from left edge to right edge */
[dir="rtl"] .sidebar-nav-link {
    border-left: none !important;
    border-right: 3px solid transparent !important;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

[dir="rtl"] .sidebar-nav-link.active {
    border-right-color: var(--color-sidebar-active-bar) !important;
}

/* Icon spacing */
[dir="rtl"] .sidebar-nav-link img.ci,
[dir="rtl"] .sidebar-nav-link .ci {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}
