/* ============================================================
   DII OS — Master Stylesheet
   assets/css/style.css
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   1. CSS VARIABLES — Brand Design System
   ============================================================ */
:root {
    /* Brand colors */
    --brand-orange:   #FF6A00;
    --brand-orange-d: #E05E00; /* hover / darker */
    --brand-orange-l: rgba(255, 106, 0, 0.10); /* tint for focus rings */

    /* Neutral palette */
    --light-bg:       #E6E6E6;
    --neutral-gray:   #9A9A9A;
    --dark-gray:      #5F5F5F;
    --dark-ui:        #1A1A1A;
    --deep-black:     #0D0D0D;

    /* Surface / card */
    --card-bg:        #FFFFFF;
    --border-light:   #DDDDDD;
    --border-mid:     #CCCCCC;

    /* Sidebar */
    --sidebar-bg:     #1A1A1A;
    --sidebar-width:  250px;
    --sidebar-text:   #B0B0B0;
    --sidebar-hover:  #242424;
    --sidebar-active: #FF6A00;

    /* Header */
    --header-bg:      #1A1A1A;
    --header-height:  60px;

    /* Status colors */
    --success:        #27AE60;
    --success-bg:     #EAFAF1;
    --warning:        #F39C12;
    --warning-bg:     #FEF9E7;
    --danger:         #E74C3C;
    --danger-bg:      #FDEDEC;
    --info:           #2980B9;
    --info-bg:        #EBF5FB;

    /* Typography */
    --font-primary:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-base: 14px;

    /* Spacing */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;

    /* Shadows */
    --shadow-sm:  0 1px 4px rgba(0,0,0,0.07);
    --shadow-md:  0 2px 12px rgba(0,0,0,0.10);
    --shadow-lg:  0 4px 24px rgba(0,0,0,0.13);

    /* Transitions */
    --transition: 0.18s ease;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); scroll-behavior: smooth; }

body {
    font-family: var(--font-primary);
    background-color: var(--light-bg);
    color: var(--dark-ui);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-orange); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul, ol { list-style: none; }

/* ============================================================
   3. LAYOUT SHELL
   ============================================================ */

/* The full-page wrapper when sidebar is present */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

/* ── Content wrapper (everything to the right of sidebar) ── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ── */
.site-header {
    height: var(--header-height);
    background: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 1px 6px rgba(0,0,0,0.3);
}

/* ── Page content ── */
.page-content {
    flex: 1;
    padding: var(--space-lg);
}

/* ── Footer ── */
.site-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-light);
    padding: var(--space-md) var(--space-lg);
    font-size: 12px;
    color: var(--neutral-gray);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================================
   4. SIDEBAR STYLES
   ============================================================ */

/* Brand / logo area at top of sidebar */
.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-logo {
    font-size: 22px;
    font-weight: 800;
    color: #FFFFFF;
    letter-spacing: -0.5px;
    line-height: 1;
}

.sidebar-logo span { color: var(--brand-orange); }

.sidebar-tagline {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--neutral-gray);
    margin-top: 2px;
}

/* Navigation */
.sidebar-nav { flex: 1; padding: var(--space-md) 0; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--dark-gray);
    padding: var(--space-md) var(--space-md) var(--space-xs);
}

.nav-item { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px var(--space-md);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 400;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-link i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #FFFFFF;
    text-decoration: none;
}

.nav-link.active {
    background: rgba(255,106,0,0.12);
    color: var(--brand-orange);
    border-left-color: var(--brand-orange);
    font-weight: 500;
}

.nav-link .nav-badge {
    margin-left: auto;
    background: var(--brand-orange);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

/* Sidebar divider */
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: var(--space-sm) var(--space-md);
}

/* Sidebar user info at bottom */
.sidebar-user {
    padding: var(--space-md);
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--neutral-gray);
}

/* ============================================================
   5. HEADER STYLES
   ============================================================ */

/* Hamburger toggle (mobile) */
.header-toggle {
    background: none;
    border: none;
    color: #FFFFFF;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: none; /* shown via media query */
}

.header-left  { display: flex; align-items: center; gap: var(--space-md); }
.header-right { display: flex; align-items: center; gap: var(--space-md); }

/* Page title in header */
.header-page-title {
    font-size: 15px;
    font-weight: 600;
    color: #FFFFFF;
}

/* Language selector */
.lang-select {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #FFFFFF;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-primary);
}

.lang-select:focus { outline: none; border-color: var(--brand-orange); }
.lang-select option { background: var(--dark-ui); color: #fff; }

/* Profile avatar / dropdown in header */
.header-profile {
    position: relative;
}

.header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition);
}

.header-avatar:hover { border-color: var(--brand-orange); }

.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 200;
    display: none;
    overflow: hidden;
}

.profile-dropdown.open { display: block; }

.profile-dropdown-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.profile-dropdown-header .pd-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-ui);
}

.profile-dropdown-header .pd-email {
    font-size: 12px;
    color: var(--neutral-gray);
    margin-top: 2px;
}

.profile-dropdown-header .pd-role {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px var(--space-md);
    font-size: 13px;
    color: var(--dark-gray);
    text-decoration: none;
    transition: background var(--transition);
}

.profile-dropdown-item:hover {
    background: var(--light-bg);
    color: var(--dark-ui);
    text-decoration: none;
}

.profile-dropdown-item.danger { color: var(--danger); }
.profile-dropdown-item.danger:hover { background: var(--danger-bg); }

/* ============================================================
   6. PAGE HEADER (below site-header, inside page-content)
   ============================================================ */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header-left h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--deep-black);
    line-height: 1.2;
}

.page-header-left .breadcrumb {
    font-size: 12px;
    color: var(--neutral-gray);
    margin-top: 3px;
}

.page-header-left .breadcrumb a { color: var(--neutral-gray); }
.page-header-left .breadcrumb a:hover { color: var(--brand-orange); }
.page-header-left .breadcrumb span { color: var(--dark-gray); }

/* ============================================================
   7. CARD COMPONENT
   ============================================================ */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.card-header h2,
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark-ui);
    margin: 0;
}

.card-body { padding: var(--space-lg); }
.card-body-sm { padding: var(--space-md); }

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: #FAFAFA;
}

/* ============================================================
   8. METRIC CARDS (Dashboard KPI tiles)
   ============================================================ */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: box-shadow var(--transition), transform var(--transition);
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.metric-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    background: var(--brand-orange-l);
    color: var(--brand-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.metric-icon.blue   { background:#EBF5FB; color:#2980B9; }
.metric-icon.green  { background:#EAFAF1; color:#27AE60; }
.metric-icon.purple { background:#F4ECF7; color:#8E44AD; }

.metric-body { flex: 1; min-width: 0; }

.metric-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--neutral-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--deep-black);
    line-height: 1.15;
    margin: 2px 0 4px;
}

.metric-value.orange { color: var(--brand-orange); }

.metric-trend {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-trend.up   { color: var(--success); }
.metric-trend.down { color: var(--danger);  }
.metric-trend.flat { color: var(--neutral-gray); }

/* ============================================================
   9. TABLE COMPONENT
   ============================================================ */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table thead th {
    background: var(--light-bg);
    color: var(--dark-gray);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--dark-ui);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover td { background: #F9F9F9; }

.data-table tfoot td {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--neutral-gray);
    border-top: 1px solid var(--border-light);
    background: #FAFAFA;
}

/* Sortable header */
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--brand-orange); }

/* ============================================================
   10. PAGINATION
   ============================================================ */

.pagination { display: flex; justify-content: center; padding: var(--space-md) 0 0; }

.pagination-list {
    display: flex;
    gap: 4px;
    list-style: none;
    flex-wrap: wrap;
}

.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--card-bg);
    color: var(--dark-gray);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}

.page-item .page-link:hover     { background: var(--light-bg); color: var(--dark-ui); text-decoration: none; }
.page-item.active .page-link    { background: var(--brand-orange); border-color: var(--brand-orange); color: #fff; }
.page-item.disabled .page-link  { pointer-events: none; opacity: 0.5; }

/* ============================================================
   11. FORM COMPONENTS
   ============================================================ */

.form-row {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group { margin-bottom: var(--space-md); }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--dark-gray);
    margin-bottom: 6px;
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-primary);
    color: var(--dark-ui);
    background: #FFFFFF;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px var(--brand-orange-l);
}

.form-control::placeholder { color: #BBBBBB; }

.form-control:disabled {
    background: var(--light-bg);
    cursor: not-allowed;
    color: var(--neutral-gray);
}

select.form-control { cursor: pointer; }

.form-hint {
    font-size: 12px;
    color: var(--neutral-gray);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(231,76,60,0.12); }

/* ============================================================
   12. BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn:active { transform: scale(0.98); }
.btn:disabled,
.btn.disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* Primary — Orange */
.btn-primary { background: var(--brand-orange); color: #fff; border-color: var(--brand-orange); }
.btn-primary:hover { background: var(--brand-orange-d); border-color: var(--brand-orange-d); text-decoration: none; color: #fff; }

/* Secondary — Dark gray */
.btn-secondary { background: var(--dark-gray); color: #fff; border-color: var(--dark-gray); }
.btn-secondary:hover { background: #4a4a4a; text-decoration: none; color: #fff; }

/* Outline */
.btn-outline { background: transparent; color: var(--brand-orange); border-color: var(--brand-orange); }
.btn-outline:hover { background: var(--brand-orange); color: #fff; text-decoration: none; }

/* Danger */
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c0392b; text-decoration: none; color: #fff; }

/* Ghost / light */
.btn-ghost { background: var(--light-bg); color: var(--dark-gray); border-color: var(--border-light); }
.btn-ghost:hover { background: var(--border-light); text-decoration: none; color: var(--dark-ui); }

/* Sizes */
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; aspect-ratio: 1; }

/* Button group */
.btn-group { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* ============================================================
   13. BADGE & STATUS PILLS
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
}

.badge-orange { background: rgba(255,106,0,0.12); color: var(--brand-orange); }
.badge-gray   { background: var(--light-bg);       color: var(--dark-gray);   }
.badge-dark   { background: rgba(26,26,26,0.10);   color: var(--dark-ui);     }
.badge-green  { background: var(--success-bg);     color: var(--success);     }
.badge-red    { background: var(--danger-bg);      color: var(--danger);      }
.badge-yellow { background: var(--warning-bg);     color: var(--warning);     }
.badge-blue   { background: var(--info-bg);        color: var(--info);        }

/* ============================================================
   14. ALERTS
   ============================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: var(--space-md);
    border-left: 4px solid transparent;
}

.alert i { font-size: 15px; flex-shrink: 0; margin-top: 2px; }
.alert span { flex: 1; }

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    font-size: 14px;
    padding: 0 2px;
    flex-shrink: 0;
}

.alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-bg); border-color: var(--success); color: #1A6635; }
.alert-error   { background: var(--danger-bg);  border-color: var(--danger);  color: #7B241C; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: #7D6608; }
.alert-info    { background: var(--info-bg);    border-color: var(--info);    color: #1A5276; }

/* ============================================================
   15. CHART CONTAINERS
   ============================================================ */

.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas { max-width: 100%; }

/* ============================================================
   16. GRID UTILITIES
   ============================================================ */

.row {
    display: grid;
    gap: var(--space-md);
}

.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.row-2-1 { grid-template-columns: 2fr 1fr; }
.row-1-2 { grid-template-columns: 1fr 2fr; }

/* ============================================================
   17. UTILITY CLASSES
   ============================================================ */

.text-orange  { color: var(--brand-orange); }
.text-gray    { color: var(--neutral-gray); }
.text-dark    { color: var(--dark-ui); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-info    { color: var(--info); }
.text-muted   { color: var(--neutral-gray); font-size: 12px; }

.font-bold   { font-weight: 700; }
.font-semi   { font-weight: 600; }
.font-normal { font-weight: 400; }

.text-sm { font-size: 12px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }

.text-center { text-align: center; }
.text-right  { text-align: right; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mb-sm { margin-bottom: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }

.d-flex   { display: flex; }
.d-none   { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

.w-100 { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-md) 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    color: var(--neutral-gray);
}

.empty-state i { font-size: 42px; margin-bottom: var(--space-md); opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,106,0,0.3);
    border-top-color: var(--brand-orange);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   18. RTL SUPPORT (Arabic)
   ============================================================ */

[dir="rtl"] .sidebar { left: auto; right: 0; }
[dir="rtl"] .main-wrapper { margin-left: 0; margin-right: var(--sidebar-width); }
[dir="rtl"] .nav-link { border-left: none; border-right: 3px solid transparent; }
[dir="rtl"] .nav-link.active { border-right-color: var(--brand-orange); }
[dir="rtl"] .site-header { flex-direction: row-reverse; }
[dir="rtl"] .page-header { flex-direction: row-reverse; }
[dir="rtl"] .alert { border-left: none; border-right: 4px solid transparent; }
[dir="rtl"] .alert-success { border-right-color: var(--success); }
[dir="rtl"] .alert-error   { border-right-color: var(--danger); }
[dir="rtl"] .alert-warning { border-right-color: var(--warning); }
[dir="rtl"] .alert-info    { border-right-color: var(--info); }
[dir="rtl"] .profile-dropdown { right: auto; left: 0; }
[dir="rtl"] .form-error { flex-direction: row-reverse; }

/* ============================================================
   19. RESPONSIVE — Tablet & Mobile
   ============================================================ */

@media (max-width: 991px) {
    .row-4 { grid-template-columns: 1fr 1fr; }
    .row-3 { grid-template-columns: 1fr 1fr; }
    .row-2-1, .row-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Collapse sidebar off-screen */
    .sidebar {
        transform: translateX(-100%);
    }

    [dir="rtl"] .sidebar { transform: translateX(100%); }

    .sidebar.open { transform: translateX(0); }

    /* Full-width content when sidebar is hidden */
    .main-wrapper { margin-left: 0; }
    [dir="rtl"] .main-wrapper { margin-right: 0; }

    /* Show hamburger */
    .header-toggle { display: flex; }

    .row-2, .row-3, .row-4, .form-row.col-2, .form-row.col-3 {
        grid-template-columns: 1fr;
    }

    .metric-grid { grid-template-columns: 1fr 1fr; }

    .page-content { padding: var(--space-md); }

    /* Overlay behind open sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
}

@media (max-width: 480px) {
    .metric-grid { grid-template-columns: 1fr; }
    .btn-group { flex-direction: column; }
    .metric-value { font-size: 22px; }
}

/* ============================================================
   20. SIDEBAR OVERLAY (mobile only, injected via JS)
   ============================================================ */
.sidebar-overlay { display: none; }
