/* ============================================
   IGH Storage Management System - Light Theme
   Arabic RTL, Responsive, Premium Design
   ============================================ */

/* Cairo font (Arabic) - self-hosted: assets/vendor/cairo/v31/cairo.css holds the @font-face rules
   and is linked in each page <head> before this file
   (an @import here delays font discovery until this file downloads, causing a late text reflow). */

/* ============================================
   CSS Variables (Light Theme)
   ============================================ */
:root {
    /* Primary palette - Professional blue */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-dark: #1e40af;
    --primary-50: #eff6ff;

    /* Secondary / Accent */
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: #ede9fe;

    /* Status colors (darkened for WCAG AA: white text on them and them on their -light tint >= 4.5:1) */
    --success: #047857;
    --success-light: #d1fae5;
    --warning: #b45309;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-text: #b91c1c; /* danger as text on --danger-light (5.3:1) */
    --danger-light: #fee2e2;
    --info: #0e7490;
    --info-light: #cffafe;

    /* Backgrounds */
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e4a7a;
    --bg-sidebar-hover: #2b6aa8;
    --bg-sidebar-active: #3b82f6;
    --bg-sidebar-submenu: #12355a;
    --bg-header: #ffffff;
    --bg-input: #ffffff;
    --bg-table-stripe: #f8fafc;
    --bg-table-hover: #eff6ff;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-sidebar: #ffffff;
    --text-sidebar-muted: #ffffff;
    --text-sidebar-active: #ffffff;
    --text-on-primary: #ffffff;

    /* Borders */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-input: #cbd5e1;
    --border-focus: #2563eb;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 0 0 1px rgba(0,0,0,.03), 0 2px 4px rgba(0,0,0,.05);

    /* Sizing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --header-height: 60px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-sm: 6px;
    --transition: all 0.2s ease;
}

/* ============================================
   Base Reset & Typography
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

/* Suppress transitions during the first paint, so state restored on load
   (collapsed sidebar, open sidebar section/submenu) appears instantly
   instead of animating into place. Class is removed by app.js after load. */
html.no-transitions *,
html.no-transitions *::before,
html.no-transitions *::after {
    transition: none !important;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* ============================================
   Layout: Sidebar + Content
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.sidebar-brand {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--header-height);
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(255,255,255,0.1);
    padding: 4px;
}

.sidebar-brand .brand-text {
    color: var(--text-sidebar);
    font-weight: 700;
    font-size: 1.2rem;
    white-space: nowrap;
}

.sidebar-menu {
    padding: 8px 0;
    list-style: none;
}

/* Collapsible Section */
.sidebar-section {
    list-style: none;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 0.936rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease, background 0.2s ease;
}

.sidebar-section-header:hover {
    background: rgba(255,255,255,0.10);
}

.sidebar-section-header .section-arrow {
    font-size: 0.84rem;
    color: var(--text-sidebar);
    transition: transform 0.25s ease;
    opacity: 1;
}

.sidebar-section.open > .sidebar-section-header .section-arrow {
    transform: rotate(-180deg);
    opacity: 1;
}

.sidebar-section.open > .sidebar-section-header {
    color: var(--text-sidebar);
    background: rgba(255,255,255,0.08);
}

/* Section body (collapsible) */
.sidebar-section-body {
    list-style: none;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-section.open > .sidebar-section-body {
    max-height: 800px;
    padding-bottom: 4px;
}

.sidebar-item {
    list-style: none;
}

.sidebar a,
.sidebar a:hover,
.sidebar a:focus,
.sidebar a:visited,
.sidebar-link,
.sidebar-link:hover,
.sidebar-link:focus,
.sidebar-link.active,
.sidebar-section-header,
.sidebar-section-header:hover {
    color: var(--text-sidebar);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 1.104rem;
    font-weight: 500;
    transition: var(--transition);
    border-right: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
}

.sidebar-link:hover i {
    opacity: 1;
    color: var(--text-sidebar);
}

.sidebar-link.active {
    background: rgba(59, 130, 246, 0.35);
    border-right-color: #93c5fd;
    border-radius: 20px;
    margin: 4px 10px;
}

.sidebar-link i {
    font-size: 1.32rem;
    width: 22px;
    text-align: center;
    opacity: 1;
    color: var(--text-sidebar);
}

.sidebar-link.active i {
    opacity: 1;
    color: var(--text-sidebar-active);
}

/* Submenu (inside a section — e.g. outgoing/incoming) */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin 0.3s ease, background 0.3s ease;
    background: transparent;
    margin: 0;
    border-radius: 8px;
    border: 1px solid transparent;
}

.sidebar-submenu.open {
    max-height: 500px;
    padding: 6px 0;
    background: var(--bg-sidebar-submenu);
    margin: 4px 10px 8px;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-submenu .sidebar-link {
    padding-right: 44px;
    font-size: 1.02rem;
    color: var(--text-sidebar);
}

.sidebar-submenu .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-sidebar);
}

.sidebar-submenu .sidebar-link.active {
    background: rgba(59, 130, 246, 0.45);
    color: var(--text-sidebar-active);
    margin: 2px 6px;
}

.sidebar-link .submenu-arrow {
    margin-right: auto;
    margin-left: 0;
    transition: transform 0.2s;
    font-size: 0.9rem;
    color: var(--text-sidebar);
    /* bi-chevron-down turned to point left (◀, the RTL reading direction) while collapsed; ▼ when expanded */
    transform: rotate(90deg);
}

.sidebar-link[aria-expanded="true"] .submenu-arrow {
    transform: rotate(0deg);
}

/* Main content area */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    max-width: calc(100vw - var(--sidebar-width));
    /* clip (not hidden): hidden would make .main-content a scroll container, so the
       sticky .top-header (and other sticky children) would never stick to the viewport */
    overflow-x: clip;
    display: flex;
    flex-direction: column;
}

@supports not (overflow: clip) {
    .main-content {
        overflow-x: hidden;
    }
}

/* Header / Navbar */
.top-header {
    background: var(--bg-header);
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

/* Bars that pin themselves to the top of the viewport must start below the (now really sticky) header.
   Hall page: its toolbar is pinned by JS with top:0 and its queue panel is sticky at top:16px
   (both written when the header still scrolled away). Higher specificity than the page's own <style>. */
.main-content .hall-toolbar.is-fixed {
    top: var(--header-height);
}

@media (min-width: 901px) {
    .main-content .hall-queue-panel {
        top: calc(var(--header-height) + 16px);
    }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
}

body.sidebar-collapsed .sidebar {
    transform: translateX(100%);
}

body.sidebar-collapsed .main-content {
    margin-right: 0;
    max-width: 100vw;
}

.sidebar-toggle:hover {
    background: var(--bg-body);
}

.page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   Quick Navigation Dropdown
   ============================================ */
.quick-nav {
    position: relative;
}

.quick-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    border: none;
    padding: 7px 14px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.quick-nav-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), #1536a0);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.quick-nav-btn .bi-grid-3x3-gap-fill { font-size: 1rem; }
.quick-nav-arrow { font-size: 0.6rem; transition: transform 0.2s; }
.quick-nav.open .quick-nav-arrow { transform: rotate(180deg); }

.quick-nav-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    z-index: 1200;
    padding: 16px;
    min-width: 480px;
    animation: qnSlideIn 0.2s ease;
}

.quick-nav.open .quick-nav-panel { display: block; }

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

.qn-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.qn-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.qn-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    padding: 6px 8px;
    background: var(--primary-50);
    border-radius: 8px;
    margin-bottom: 2px;
    border-right: 3px solid var(--primary);
}
.qn-section-header i { font-size: 0.9rem; }

.qn-header-incoming {
    color: var(--success);
    background: var(--success-light);
    border-right-color: var(--success);
}

.qn-header-clothes {
    color: var(--accent);
    background: var(--accent-light);
    border-right-color: var(--accent);
}

.qn-header-inventory {
    color: var(--warning);
    background: var(--warning-light);
    border-right-color: var(--warning);
}

.qn-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s ease;
    font-weight: 500;
}

.qn-link:hover {
    background: var(--bg-body);
    color: var(--primary);
    transform: translateX(-2px);
}

.qn-link i {
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.qn-link:hover i { opacity: 1; }

/* ============================================
   Notification Center
   ============================================ */
.notification-center {
    position: relative;
}

.notif-bell-btn {
    position: relative;
    background: none;
    border: 1px solid var(--border-color);
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.15rem;
    transition: all 0.2s;
}
.notif-bell-btn:hover {
    background: var(--bg-body);
    color: var(--primary);
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: var(--text-on-primary);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 4px;
    animation: notifPulse 2s ease-in-out infinite;
}

@keyframes notifPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.notif-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.14);
    z-index: 1200;
    width: 340px;
    max-height: 420px;
    animation: qnSlideIn 0.2s ease;
    overflow: hidden;
}

.notification-center.open .notif-panel { display: block; }

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.notif-header i { color: var(--primary); }

.notif-mark-all {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    font-weight: 600;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-list {
    max-height: 350px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
    cursor: default;
    transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-body); }
.notif-item.unread { background: var(--primary-50); }

.notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    background: var(--info-light);
    color: var(--info);
}
.notif-icon.notif-new { background: var(--warning-light); color: var(--warning); }
.notif-icon.notif-sent { background: var(--info-light); color: var(--info); }
.notif-icon.notif-delivered { background: var(--success-light); color: var(--success); }
.notif-icon.notif-returned { background: var(--danger-light); color: var(--danger); }

.notif-content { flex: 1; min-width: 0; }
.notif-content .notif-msg {
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}
.notif-content .notif-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 2px;
}

.notif-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.user-dropdown-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ============================================
   Content Area
   ============================================ */
.content-wrapper {
    flex: 1;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i {
    color: var(--primary);
}

.breadcrumb-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb-custom a {
    color: var(--text-secondary);
}

.breadcrumb-custom span {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h5 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-table-stripe);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* Stat Cards */
.stat-card {
    padding: 20px;
    border-radius: var(--border-radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.stat-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.stat-primary::after { background: var(--primary); }
.stat-card.stat-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.stat-success::after { background: var(--success); }
.stat-card.stat-warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.stat-warning::after { background: var(--warning); }
.stat-card.stat-danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.stat-danger::after { background: var(--danger); }
.stat-card.stat-info .stat-icon { background: var(--info-light); color: var(--info); }
.stat-card.stat-info::after { background: var(--info); }

/* Stat cards given an inline gradient background (dashboard): dark slate text is unreadable on them */
.stat-card[style*="gradient"] .stat-value,
.stat-card[style*="gradient"] .stat-label {
    color: var(--text-on-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--text-on-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-success {
    background: var(--success);
    color: var(--text-on-primary);
    border-color: var(--success);
}
.btn-success:hover {
    background: #065f46;
    border-color: #065f46;
    color: var(--text-on-primary);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-on-primary);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-text);
    border-color: var(--danger-text);
    color: var(--text-on-primary);
}

.btn-warning {
    background: var(--warning);
    color: var(--text-on-primary);
    border-color: var(--warning);
}
.btn-warning:hover {
    background: #92400e;
    border-color: #92400e;
    color: var(--text-on-primary);
}

.btn-info {
    background: var(--info);
    color: var(--text-on-primary);
    border-color: var(--info);
}
.btn-info:hover {
    background: #155e75;
    border-color: #155e75;
    color: var(--text-on-primary);
}

.btn-outline-success {
    background: transparent;
    color: var(--success);
    border-color: var(--success);
}
.btn-outline-success:hover {
    background: var(--success);
    color: var(--text-on-primary);
}

.btn-outline-info {
    background: transparent;
    color: var(--info);
    border-color: var(--info);
}
.btn-outline-info:hover {
    background: var(--info);
    color: var(--text-on-primary);
}

.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-outline-danger:hover {
    background: var(--danger);
    color: var(--text-on-primary);
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: var(--text-on-primary);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-outline-secondary:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.btn-light {
    background: var(--bg-body);
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-light:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

.btn-icon {
    padding: 6px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
    padding: 4px;
}

/* Button group (RTL: first button is on the right) */
.btn-group {
    display: inline-flex;
    align-items: stretch;
}
.btn-group > .btn {
    border-radius: 0;
}
.btn-group > .btn + .btn {
    margin-inline-start: -1px;
}
.btn-group > .btn:first-child {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
.btn-group > .btn:last-child {
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}
.btn-group > .btn:only-child {
    border-radius: var(--border-radius);
}

/* Bootstrap-style close button (empty <button class="btn-close">) */
.btn-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 1.4rem;
    line-height: 1;
    transition: var(--transition);
}
.btn-close:empty::before {
    content: "\00d7";
}
.btn-close:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

/* Keyboard focus ring */
.btn:focus-visible,
.btn-icon:focus-visible,
.btn-close:focus-visible,
.actions-kebab:focus-visible,
.modal-close:focus-visible,
.sidebar-toggle:focus-visible,
.quick-nav-btn:focus-visible,
.notif-bell-btn:focus-visible,
.user-dropdown-btn:focus-visible,
.actions-drop-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sidebar a:focus-visible,
.sidebar-link:focus-visible,
.sidebar-section-header:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: -2px;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
    margin-right: 2px;
}

.form-control, .form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    direction: rtl;
}

/* Dates, times, numbers, phones, e-mails and URLs are left-to-right content: inheriting
   direction:rtl from .form-control mirrors the date/time segment order in Chromium.
   Kept right-aligned to line up with the other (RTL) fields; an Arabic placeholder
   is shown RTL while the field is empty. */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="url"] {
    direction: ltr;
}

/* zero specificity: any field that sets its own text-align (e.g. centred quantities) keeps it */
:where(input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="number"],
input[type="tel"],
input[type="email"],
input[type="url"]) {
    text-align: right;
}

input[type="number"]:placeholder-shown,
input[type="tel"]:placeholder-shown,
input[type="email"]:placeholder-shown,
input[type="url"]:placeholder-shown {
    direction: rtl;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.form-control-sm {
    padding: 5px 8px;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled, .form-select:disabled {
    background: var(--bg-body);
    opacity: 0.7;
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.input-group {
    display: flex;
    gap: 0;
}

.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.input-group .form-control:last-child {
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.input-group .input-group-text {
    padding: 9px 12px;
    background: var(--bg-body);
    border: 1px solid var(--border-input);
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ============================================
   Tables
   ============================================ */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius);
    -webkit-overflow-scrolling: touch;
}

/* Force DataTables wrapper to stay within card */
.dataTables_wrapper {
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    max-width: 100%;
}

.dataTables_scrollBody {
    overflow-x: auto !important;
}

/* Exactly one horizontal scroller per table:
   - scrollX tables (initDataTable): only DataTables' own .dataTables_scrollBody scrolls
     (its header strip is kept in sync by DataTables), so the wrapper and .table-responsive don't;
   - plain DataTables (no scrollX): the .dataTables_wrapper scrolls, .table-responsive doesn't;
   - plain tables (no DataTables): .table-responsive scrolls as before.
   The sticky last/actions column sticks to its nearest scroller, which is unchanged in each case. */
.table-responsive:has(> .dataTables_wrapper) {
    overflow-x: visible;
}

.dataTables_wrapper:has(> .dataTables_scroll) {
    overflow-x: visible;
}

table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 600px;
}

table.dataTable thead th {
    background: var(--bg-body);
    color: var(--text-secondary);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

table.dataTable tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

table.dataTable tbody tr:hover {
    background: var(--bg-table-hover);
}

table.dataTable tbody tr:nth-child(even) {
    background: var(--bg-table-stripe);
}

table.dataTable tbody tr:nth-child(even):hover {
    background: var(--bg-table-hover);
}

/* DataTables controls */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 12px 0;
}

.dataTables_wrapper .dataTables_length select {
    padding: 4px 8px;
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius-sm);
    background: var(--bg-input);
    font-family: inherit;
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_filter input {
    padding: 6px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.85rem;
    margin-right: 8px;
    transition: var(--transition);
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.dataTables_wrapper .dataTables_info {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-top: 12px;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 12px;
}

/* Pagination buttons. The vendor sheet (jquery.dataTables.min.css) styles the states
   .disabled / :active (0,4,0) and .disabled:hover / .disabled:active / .current:hover (0,5,0);
   the state selectors below match those specificities and come later, so border/background
   win without !important. Colours keep !important: the vendor sets color with !important. */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 10px;
    margin: 0 2px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary) !important;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_paginate .paginate_button:active,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    color: var(--text-on-primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: default;
}

/* Action buttons column */
.actions-cell {
    position: relative;
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
}

.actions-cell .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
}

/* Desktop: show inline, hide dropdown */
.actions-inline {
    display: flex;
    gap: 4px;
    align-items: center;
}

.actions-dropdown {
    display: none;
    position: relative;
}

/* Kebab button */
.actions-kebab {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: var(--transition);
}

.actions-kebab:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* Dropdown menu — fixed position to escape overflow containers */
.actions-drop-menu {
    display: none;
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 9999;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.actions-drop-menu.show {
    display: block;
}

.actions-drop-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    background: none;
    border: none;
    width: 100%;
    text-align: right;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    white-space: nowrap;
}

.actions-drop-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.actions-drop-item i {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    opacity: 0.7;
}

.actions-drop-danger {
    color: var(--danger);
}

.actions-drop-danger:hover {
    background: var(--danger-light);
    color: var(--danger-text);
}

/* Mobile: collapse all action buttons into kebab menu */
@media (max-width: 768px) {
    /* Hide all direct buttons/links inside actions-cell */
    .actions-cell > .btn,
    .actions-cell > a,
    .actions-cell > button,
    .actions-cell > .actions-inline {
        display: none !important;
    }
    /* Show the auto-injected kebab */
    .actions-cell > .actions-dropdown {
        display: block !important;
    }
}

/* Sticky action column (last column) — sticks to left in RTL */
table.dataTable th:last-child,
table.dataTable td:last-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-card);
}

table.dataTable tbody tr:nth-child(even) td:last-child {
    background: var(--bg-table-stripe);
}

table.dataTable tbody tr:hover td:last-child {
    background: var(--bg-table-hover);
}

table.dataTable thead th:last-child {
    background: var(--bg-body);
    z-index: 3;
}

/* Shadow on sticky column to hint scrollability */
table.dataTable td:last-child::before {
    content: '';
    position: absolute;
    top: 0;
    right: 100%;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to left, rgba(0,0,0,0.06), transparent);
    pointer-events: none;
}

/* ============================================
   Status Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-draft { background: var(--bg-body); color: var(--text-secondary); border: 1px solid var(--border-color); }
.badge-sent { background: var(--info-light); color: var(--info); }
.badge-in_progress { background: var(--warning-light); color: var(--warning); }

/* Read-only record details modal */
.details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px;
    padding: 12px 14px; background: var(--bg-body); border-radius: 8px; margin-bottom: 14px; font-size: 0.85rem; }
.details-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.details-field.details-wide { grid-column: 1 / -1; }
.details-label { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; }
.details-value { color: var(--text-primary); font-weight: 600; white-space: pre-wrap; word-break: break-word; }
.details-items-title { font-weight: 700; margin-bottom: 8px; font-size: 0.9rem; }
.details-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.details-table th { padding: 8px 10px; background: var(--bg-body); border-bottom: 2px solid var(--border-color); text-align: right; white-space: nowrap; }
.details-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); }
.details-table .num { text-align: center; white-space: nowrap; }
.badge-delivered { background: var(--success-light); color: var(--success); }
.badge-reviewed { background: var(--primary-light); color: var(--primary); }
.badge-returned { background: var(--danger-light); color: var(--danger-text); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--bg-body); color: var(--text-muted); }

/* ============================================
   Modals
   ============================================ */
.modal-backdrop {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1050;
    display: none;
    animation: fadeIn 0.2s ease;
}

.modal-backdrop.show {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
    animation: modalSlideIn 0.3s ease forwards;
}

.modal.show {
    display: block;
}

.modal.modal-lg {
    max-width: 900px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h5 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-start;
    gap: 8px;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { transform: translate(-50%, -50%) scale(0.95); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideInRight 0.4s ease;
    /* Hold the start frame during animation-delay (dashboard cards are staggered),
       otherwise they show, vanish, then slide in. "backwards" (not "both") keeps :hover transforms working. */
    animation-fill-mode: backwards;
}

/* Login card entrance — must not use modalSlideIn, whose translate(-50%,-50%)
   is only correct for fixed, centered modals and made the card jump into place. */
@keyframes loginCardIn {
    from { transform: translateY(16px) scale(0.98); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* ============================================
   Grid
   ============================================ */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;
}

.col { flex: 1; padding: 0 8px; }
.col-1 { flex: 0 0 8.333%; max-width: 8.333%; padding: 0 8px; }
.col-2 { flex: 0 0 16.666%; max-width: 16.666%; padding: 0 8px; }
.col-3 { flex: 0 0 25%; max-width: 25%; padding: 0 8px; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 0 8px; }
.col-5 { flex: 0 0 41.666%; max-width: 41.666%; padding: 0 8px; }
.col-6 { flex: 0 0 50%; max-width: 50%; padding: 0 8px; }
.col-7 { flex: 0 0 58.333%; max-width: 58.333%; padding: 0 8px; }
.col-8 { flex: 0 0 66.666%; max-width: 66.666%; padding: 0 8px; }
.col-9 { flex: 0 0 75%; max-width: 75%; padding: 0 8px; }
.col-10 { flex: 0 0 83.333%; max-width: 83.333%; padding: 0 8px; }
.col-11 { flex: 0 0 91.666%; max-width: 91.666%; padding: 0 8px; }
.col-12 { flex: 0 0 100%; max-width: 100%; padding: 0 8px; }

/* Responsive columns actually used (mobile-first: full width below the breakpoint) */
.col-lg-9,
.col-xl-7 { flex: 0 0 100%; max-width: 100%; padding: 0 8px; }
@media (min-width: 992px) {
    .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
}
@media (min-width: 1200px) {
    .col-xl-7 { flex: 0 0 58.333%; max-width: 58.333%; }
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }

/* A .row already has horizontal gutters (negative margin + column padding), so a gap-*
   utility on it must only add vertical spacing; a column-gap on top of the percentage
   widths made col-6 + col-6 / 4 x col-3 overflow and wrap. The gutter is resized to
   match the gap size so the horizontal spacing equals the requested gap. */
.row.gap-1, .row.gap-2, .row.gap-3, .row.gap-4 { column-gap: 0; }
.row.gap-1 { margin-left: -2px; margin-right: -2px; }
.row.gap-1 > [class*="col-"], .row.gap-1 > .col { padding-left: 2px; padding-right: 2px; }
.row.gap-2 { margin-left: -4px; margin-right: -4px; }
.row.gap-2 > [class*="col-"], .row.gap-2 > .col { padding-left: 4px; padding-right: 4px; }
/* .row.gap-3: the default 8px column padding already gives a 16px gutter */
.row.gap-4 { margin-left: -12px; margin-right: -12px; }
.row.gap-4 > [class*="col-"], .row.gap-4 > .col { padding-left: 12px; padding-right: 12px; }

/* Utilities */
.d-flex { display: flex; }
.d-none { display: none; }
.d-block { display: block; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-start { text-align: right; }
.text-end { text-align: left; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fs-1 { font-size: 2.5rem; }
.fs-sm { font-size: 0.85rem; }
.fs-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.me-1 { margin-left: 4px; }
.me-2 { margin-left: 8px; }
.ms-1 { margin-right: 4px; }
.ms-2 { margin-right: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 16px; padding-bottom: 16px; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }
.py-5 { padding-top: 40px; padding-bottom: 40px; }
.px-3 { padding-right: 16px; padding-left: 16px; }
.w-100 { width: 100%; }
.container-fluid { width: 100%; padding-left: 12px; padding-right: 12px; }

/* Alerts (Bootstrap-style) */
.alert {
    display: block;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.6;
}
.alert-info { background: var(--info-light); color: var(--info); border-color: rgba(14, 116, 144, 0.2); }
.alert-success { background: var(--success-light); color: var(--success); border-color: rgba(4, 120, 87, 0.2); }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: rgba(180, 83, 9, 0.2); }
.alert-danger { background: var(--danger-light); color: var(--danger-text); border-color: rgba(220, 38, 38, 0.2); }
.alert-secondary { background: var(--bg-body); color: var(--text-secondary); border-color: var(--border-color); }

/* Minimal Bootstrap-style table (used in modal detail tables) */
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 12px; }
.table th { padding: 8px 10px; background: var(--bg-body); border-bottom: 2px solid var(--border-color); text-align: right; white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table-sm th, .table-sm td { padding: 5px 8px; }

/* Toast customization */
.toast-container {
    direction: rtl;
}

/* ============================================
   Login Page
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    animation: loginCardIn 0.4s ease;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .login-logo img {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
}

.login-card .login-logo h3 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-card .login-logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.login-card .login-error {
    background: var(--danger-light);
    color: var(--danger-text);
    padding: 10px 14px;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: block;
}

.empty-state h4 {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============================================
   Permissions Matrix Table
   ============================================ */
.permissions-table {
    width: 100%;
    border-collapse: collapse;
}

.permissions-table th,
.permissions-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}

.permissions-table th:first-child,
.permissions-table td:first-child {
    text-align: right;
    font-weight: 600;
}

.permissions-table thead th {
    background: var(--bg-body);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.permissions-table tbody tr:hover {
    background: var(--bg-table-hover);
}

/* ============================================
   Flash Messages
   ============================================ */
.flash-message {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    animation: slideInRight 0.3s ease;
}

.flash-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.flash-error {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ============================================
   Sidebar Overlay (Mobile)
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    backdrop-filter: blur(2px);
}

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

/* ============================================
   Select2 RTL Overrides
   (single block: an earlier duplicate was merged here, keeping the values that won the cascade)
   ============================================ */
.select2-container {
    direction: rtl;
    text-align: right;
}

.select2-container .select2-selection--single {
    padding: 4px 12px;
}

.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    direction: rtl;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-right: 12px;
    padding-left: 30px;
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
}

/* Arrow on the LEFT (RTL) */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    right: auto;
    left: 4px;
    height: 36px;
}

/* Clear button on the LEFT, before the arrow */
.select2-container--default .select2-selection--single .select2-selection__clear {
    float: left;
    margin-left: 4px;
    margin-right: 0;
    font-size: 1.1rem;
    line-height: 36px;
    color: var(--text-muted);
    cursor: pointer;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--danger);
}

/* Dropdown */
.select2-dropdown {
    border-color: var(--border-input);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    direction: rtl;
    font-family: 'Cairo', sans-serif;
    z-index: 1085;
}

.modal .select2-container--open {
    z-index: 1086;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius-sm);
    padding: 6px 10px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    direction: rtl;
}

.select2-results__option {
    padding: 8px 12px;
    font-size: 0.88rem;
}

.select2-results__option--highlighted {
    background-color: var(--primary) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--primary);
}

/* Focus state */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* ============================================
   Default-password warning banner (header.php)
   ============================================ */
.default-pw-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    margin: 16px 24px 0;
    padding: 12px 16px;
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid rgba(180, 83, 9, 0.3);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
}

.default-pw-banner-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.default-pw-banner-text {
    flex: 1 1 260px;
    min-width: 0;
}

.default-pw-banner-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--border-radius-sm);
    line-height: 1;
}

.default-pw-banner-close:hover,
.default-pw-banner-close:focus-visible {
    background: rgba(180, 83, 9, 0.12);
}

@media (max-width: 767.98px) {
    .default-pw-banner {
        margin: 12px 12px 0;
    }
}

@media print {
    .default-pw-banner {
        display: none !important;
    }
}

/* ============================================
   Change-password dialog (SweetAlert2, app.js)
   ============================================ */
.cpw-popup .swal2-html-container {
    margin: 12px 1.2em 4px;
    text-align: right;
    overflow: visible;
}

.cpw-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cpw-field .form-label {
    display: block;
    margin-bottom: 6px;
}

.cpw-input-wrap {
    position: relative;
}

.cpw-input-wrap .form-control {
    width: 100%;
    padding-left: 42px;
    text-align: right;
}

.cpw-toggle {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    line-height: 1;
}

.cpw-toggle:hover,
.cpw-toggle:focus-visible {
    color: var(--text-primary);
    background: var(--border-light);
}

.cpw-hint {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
