/* ===== JAGUAR ERP - MODERN UNIFIED DESIGN SYSTEM (V2.0) ===== */
/* Fully Redesigned for a modern, professional, and Arabic-first experience */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

/* ===== 1. DESIGN TOKENS & VARIABLES ===== */
:root {
    /* PRIMARY BRAND COLORS - Elegant Gold & Deep Slate */
    --brand-gold: #C5A028;
    --brand-gold-light: #D4AF37;
    --brand-gold-dark: #A6830C;
    --brand-gold-gradient: linear-gradient(135deg, #A6830C 0%, #C5A028 50%, #8E6F0A 100%);

    --brand-slate: #1E293B;
    --brand-slate-light: #334155;
    --brand-slate-dark: #0F172A;
    --brand-slate-extra-dark: #020617;

    /* NEUTRAL PALETTE */
    --white: #FFFFFF;
    --bg-light: #F8FAFC;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    /* STATUS COLORS */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;

    /* SHADOWS & EFFECTS */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-gold: 0 4px 15px rgba(197, 160, 40, 0.3);

    /* BORDER RADIUS */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* TYPOGRAPHY */
    --font-base: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    --size-xs: 0.75rem;
    --size-sm: 0.875rem;
    --size-base: 1rem;
    --size-lg: 1.125rem;
    --size-xl: 1.25rem;
    --size-2xl: 1.5rem;

    /* LAYOUT */
    --sidebar-width: 260px;
    --header-height: 70px;
}

/* ===== 2. GLOBAL RESET & BASE STYLES ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-base);
    background-color: var(--bg-light);
    color: var(--gray-800);
    font-size: var(--size-sm);
    line-height: 1.6;
    overflow-x: hidden;
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand-gold);
}

/* ===== 3. LAYOUT COMPONENTS ===== */

/* Main Header */
.main-header {
    height: var(--header-height);
    background: var(--brand-slate-dark);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    /* Fixed header */
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    border-bottom: 2px solid var(--brand-gold);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.jaguar-logo {
    height: 45px;
    width: auto;
    filter: drop-shadow(0 0 5px rgba(197, 160, 40, 0.5));
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand-gold);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.system-subtitle {
    font-size: 0.7rem;
    color: var(--brand-gold-light);
    font-weight: 500;
    opacity: 0.8;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #111827;
    /* Deep Navy from reference */
    height: 100vh;
    position: fixed;
    top: 0;
    padding-top: var(--header-height);
    transition: all 0.3s ease;
    z-index: 900;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    overflow-x: hidden;
    border: none !important;
}

[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
}

[dir="ltr"] .sidebar {
    left: 0;
    right: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 1.5rem 0;
    /* Remove horizontal padding for pill effect */
}

.sidebar-menu li {
    margin-bottom: 0.25rem;
}

.sidebar-menu a,
.section-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.5rem;
    color: #ffffff;
    /* High visibility white text */
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    position: relative;
    border-radius: 0;
    /* Reset for pill */
}

/* Pill Shape Logic - Rounded only on the inner side */
[dir="rtl"] .sidebar-menu a,
[dir="rtl"] .section-toggle {
    border-radius: 50px 0 0 50px;
    margin-right: 0;
    margin-left: 1rem;
}

[dir="ltr"] .sidebar-menu a,
[dir="ltr"] .section-toggle {
    border-radius: 0 50px 50px 0;
    margin-left: 0;
    margin-right: 1rem;
}

/* Icons */
.sidebar-menu .menu-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: #c49b29;
    /* Standard gold icons */
    opacity: 1;
}

/* Hover States - Gold Gradient */
.sidebar-menu a:hover,
.section-toggle:hover {
    background: linear-gradient(90deg, #f1e8cd 0%, #ffdb64 100%);
    color: #000000 !important;
}

.sidebar-menu a:hover .menu-icon,
.section-toggle:hover .menu-icon {
    color: #000000 !important;
}

/* Active State */
.sidebar-menu a.active {
    background: linear-gradient(90deg, #b08d26 0%, #d4af37 100%);
    color: #000000 !important;
}

.sidebar-menu a.active .menu-icon {
    color: #000000 !important;
}

/* Special Gold Item (Reference Page/Home) */
.menu-item-gold {
    background: linear-gradient(90deg, #b08d26 0%, #d4af37 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.menu-item-gold .menu-icon {
    color: #ffffff !important;
    opacity: 1 !important;
}

/* Sidebar Sections (Toggles) */
.sidebar-section {
    margin-top: 0.25rem;
}

.section-toggle {
    padding-top: 1rem;
    padding-bottom: 1rem;
    color: #f1f5f9;
    /* Lighter color for header items */
}

.section-toggle .menu-icon {
    color: #b08d26;
    /* Gold icons for headers */
    opacity: 1;
}

.toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    opacity: 0.5;
}

/* Submenu Styling */
.submenu {
    list-style: none;
    margin: 0.25rem 0;
    background: rgba(0, 0, 0, 0.15);
    /* Slightly darker for contrast */
}

.submenu a {
    padding: 0.7rem 2rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

/* Main Content Wrapper Adjustments */
.layout-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    padding-top: var(--header-height);
    /* Ensure content is below header */
}

.main-content {
    flex: 1;
    padding: 2rem;
    transition: all 0.3s ease;
    min-width: 0;
    /* Prevent flex-item from overflowing */
}

[dir="rtl"] .main-content {
    margin-right: var(--sidebar-width) !important;
    margin-left: 0 !important;
}

[dir="ltr"] .main-content {
    margin-left: var(--sidebar-width) !important;
    margin-right: 0 !important;
}

/* Responsive Content */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(100%);
    }

    [dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    [dir="rtl"] .main-content,
    [dir="ltr"] .main-content {
        margin: 0 !important;
    }
}

/* Pagination Modern Styling */
.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    gap: 0.25rem;
    align-items: center;
}

.page-link {
    position: relative;
    display: block;
    padding: 0.5rem 0.85rem;
    color: var(--gray-700);
    text-decoration: none;
    background-color: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 38px;
    text-align: center;
}

.page-link:hover {
    z-index: 2;
    color: var(--brand-slate-dark);
    background-color: var(--gray-100);
    border-color: var(--brand-gold);
}

.page-item.active .page-link {
    z-index: 3;
    color: var(--brand-slate-dark);
    background: var(--brand-gold-gradient);
    border-color: var(--brand-gold);
}

.page-item.disabled .page-link {
    color: var(--gray-400);
    pointer-events: none;
    background-color: var(--white);
    border-color: var(--gray-200);
    opacity: 0.6;
}

/* Filters Modern Styling */
.filter-section {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* ===== 4. MODERN COMPONENTS ===== */

/* Page Header */
.page-header,
.jaguar-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title-wrapper,
.jaguar-page-title-wrapper {
    display: flex;
    flex-direction: column;
}

.page-title,
.jaguar-page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--brand-slate-dark);
    margin: 0;
}

.page-subtitle,
.jaguar-page-subtitle {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.page-actions,
.jaguar-page-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Cards */
.card,
.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.stat-card {
    border-top: 4px solid var(--brand-gold);
}

.stat-label {
    color: var(--gray-500);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--brand-slate-dark);
    line-height: 1;
}

/* Tables */
.table-responsive {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 2px solid var(--gray-200);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--brand-slate-dark);
    color: var(--brand-gold);
    padding: 1rem;
    font-weight: 900;
    text-align: inherit;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    font-weight: 700;
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: var(--brand-gold-gradient);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-primary,
.btn-primary:active,
.btn-primary:focus {
    background: var(--brand-gold-gradient) !important;
    color: var(--brand-slate-dark) !important;
    border: none !important;
    box-shadow: var(--shadow-gold) !important;
}

.btn-outline-primary {
    border: 1px solid var(--brand-gold) !important;
    color: var(--brand-gold) !important;
    background: transparent !important;
}

.btn-outline-primary:hover {
    background: var(--brand-gold) !important;
    color: var(--white) !important;
}

.btn-danger {
    background: #EF4444 !important;
    color: white !important;
    border: none !important;
}

/* Tables Custom Overrides */
.table-dark {
    --bs-table-bg: var(--brand-slate-dark) !important;
    --bs-table-color: var(--brand-gold) !important;
}

.table-responsive {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 1rem 1.25rem !important;
    font-size: 1rem !important;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--brand-gold) !important;
    background: var(--brand-slate-dark) !important;
    color: var(--brand-gold) !important;
}


.table td {
    padding: 0.3rem 0.3rem !important;
    vertical-align: middle !important;
    border-bottom: 2px solid var(--gray-300) !important;
}

/* Style for the first column (Serial Number #) */
.table td:first-child {
    background-color: var(--brand-gold-light) !important;
    color: var(--brand-slate-dark) !important;
    font-weight: 800 !important;
    text-align: center !important;
    border-inline-end: 1px solid var(--brand-slate-dark) !important;
    width: 50px;
}

/* Zebra Stripes - Alternate row colors */
.table tbody tr:nth-of-type(even) {
    background-color: rgba(219, 69, 27, 0.02) !important;
    /* Very subtle dark slate */
}

/* Gold Hover Effect */
.table tbody tr:hover {
    background-color: rgba(247, 191, 7, 0.08) !important;
    /* Very light gold hover */
}

.table tr:last-child td {
    border-bottom: none !important;
}

/* Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-error {
    background: #FEE2E2;
    color: #991B1B;
}

/* ===== 5. UTILITIES ===== */
.text-gold {
    color: var(--brand-gold);
}

.bg-gold {
    background: var(--brand-gold);
}

.shadow-gold {
    box-shadow: var(--shadow-gold);
}

/* User Profile Dropdown Modern */
.user-profile-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--brand-gold);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
}

.user-profile-btn:hover {
    background: var(--brand-gold);
    color: var(--brand-slate-dark);
}

/* Toast Modern */
.toast-container {
    z-index: 2000;
}

.toast-notification {
    background: var(--white);
    border-right: 4px solid var(--brand-gold);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--brand-slate-dark);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    min-width: 300px;
    max-width: 450px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    position: relative;
    overflow: hidden;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-notification.hide {
    opacity: 0;
    transform: translateX(100px);
}

.toast-icon {
    font-size: 1.25rem;
    margin-top: 0.1rem;
}

.toast-icon-success {
    color: var(--success);
}

.toast-icon-error {
    color: var(--error);
}

.toast-icon-warning {
    color: var(--warning);
}

.toast-icon-info {
    color: var(--info);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--brand-slate-dark);
}

.toast-message {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin: 0;
}

.toast-close {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.2rem;
    padding: 0;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--brand-slate-dark);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--brand-gold);
    width: 100%;
    transform-origin: left;
}

.toast-stack-animation {
    animation: toastStack 0.3s ease forwards;
}

@keyframes toastStack {
    from {
        margin-bottom: 0rem;
    }

    to {
        margin-bottom: 0.75rem;
    }
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--brand-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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