@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Vazirmatn:wght@300;400;500;700&display=swap');

:root {
    /* Sleek Cyber & Colorful Minimalist Palette */
    --primary: #4318FF;       /* Electric Blue */
    --primary-hover: #3311DB;
    --primary-light: #E9E3FF;
    
    /* Vibrant Gradients */
    --grad-primary: linear-gradient(135deg, #868CFF 0%, #4318FF 100%);
    --grad-success: linear-gradient(135deg, #05CD99 0%, #43E97B 100%);
    --grad-danger:  linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    --grad-warning: linear-gradient(135deg, #FFCE00 0%, #FF9A44 100%);
    
    /* Layout Colors */
    --background: #F4F7FE;    /* Soft Cool Gray/Blue for main area */
    --surface: #FFFFFF;       /* Pure white for cards */
    --border: #E0E5F2;
    
    /* Typography */
    --text-main: #2B3674;     /* Deep Navy for main text */
    --text-muted: #A3AED0;    /* Soft Gray/Blue */
    
    /* Smooth Effects */
    --shadow-soft: 0 10px 40px -10px rgba(67, 24, 255, 0.08);
    --shadow-hover: 0 20px 40px -10px rgba(67, 24, 255, 0.15);
    --shadow-btn: 0 8px 20px rgba(67, 24, 255, 0.25);
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background-color: var(--background);
    color: var(--text-main);
    /* Highly Formal, Professional Kurdish Typography */
    font-family: 'IBM Plex Sans Arabic', 'Vazirmatn', Tahoma, sans-serif;
    margin: 0;
    padding: 0;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.2px;
}

/* ==========================================
   LAYOUT
========================================== */
.app-container { display: flex; min-height: 100vh; }
.main-content { flex: 1; padding: 40px 50px; margin-right: 280px; transition: var(--transition); }

/* ==========================================
   PREMIUM SAAS SIDEBAR
========================================== */
.sidebar {
    background-color: var(--surface);
    width: 280px;
    position: fixed;
    top: 0; bottom: 0; right: 0;
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 40px rgba(43, 54, 116, 0.03); /* Beautiful soft floating shadow */
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 32px 24px 24px 24px;
    text-align: center;
}

.sidebar .logo {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sidebar .logo-icon {
    width: 48px; height: 48px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}

.sidebar .logo-text {
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Navigation Links */
.nav {
    flex: 1;
    overflow-y: auto;
    padding-top: 10px;
}

.nav-item {
    color: #8F9BBA;
    background: transparent;
    border: none;
    padding: 14px 20px;
    margin: 6px 20px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.nav-item i {
    font-size: 20px;
    transition: var(--transition);
}

/* Hover State */
.nav-item:hover {
    background-color: var(--background);
    color: var(--primary);
    transform: translateX(-4px); /* Subtle slide left in RTL */
}

/* Active State - Vibrant Pill Button */
.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-btn);
    font-weight: 600;
}

.nav-item.active i {
    color: white;
}
/* Sidebar Dropdown Menu (Submenu) */
.nav-dropdown-toggle { justify-content: space-between; width: calc(100% - 32px); }
.nav-submenu { 
    display: none; /* Hidden by default */
    padding-right: 15px; /* Indent for RTL */
    margin-top: 4px;
    border-right: 2px solid var(--border); /* Visual line connecting sub-items */
    margin-right: 30px;
}
.nav-submenu.show { display: block; } /* Class to slide it open */
.nav-submenu .nav-item { 
    padding: 10px 15px; 
    margin: 2px 10px; 
    font-size: 14px; 
}
.nav-submenu .nav-item i { font-size: 14px; }

/* User Info Panel (Bottom of Sidebar) */
.user-info {
    margin: 20px;
    padding: 20px;
    background: var(--background);
    border-radius: 20px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.user-profile { 
    display: flex; 
    align-items: center; 
    gap: 14px; 
    margin-bottom: 20px; 
}

.user-avatar {
    width: 45px; height: 45px; 
    border-radius: 14px;
    background: var(--grad-primary);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem;
    box-shadow: var(--shadow-btn);
}

.user-details h4 { margin: 0 0 4px 0; font-size: 1rem; color: var(--text-main); font-weight: 700; }
.user-details span { font-size: 0.8rem; color: var(--text-muted); }

.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 12px;
    background: white;
    color: #FF6B6B;
    border: 1px solid #FFEEEE;
    border-radius: 12px;
    font-weight: 600; font-size: 0.95rem; text-decoration: none;
    transition: var(--transition); box-sizing: border-box;
}

.btn-logout:hover {
    background: var(--grad-danger);
    color: white; border-color: transparent;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
    transform: translateY(-2px);
}

/* ==========================================
   UI COMPONENTS (Cards, Tables, Badges)
========================================== */
.page-header { margin-bottom: 40px; }
.page-title { font-size: 2.2rem; font-weight: 700; color: var(--text-main); margin: 0 0 8px 0; }
.page-subtitle { color: #8F9BBA; margin: 0; font-size: 1.1rem; font-weight: 500; }

.card {
    background: var(--surface);
    border: none; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 32px; margin-bottom: 30px; transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; padding-bottom: 0; border: none;
}
.card-title { font-size: 1.3rem; font-weight: 700; margin: 0; color: var(--text-main); display: flex; align-items: center; gap: 12px; }

.table-container { overflow-x: auto; border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: right; }
.table th {
    background: transparent; color: #8F9BBA;
    font-weight: 600; padding: 16px 20px; font-size: 0.95rem;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td {
    padding: 18px 20px; border-bottom: 1px solid var(--border);
    color: var(--text-main); vertical-align: middle; font-weight: 500;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: #FAFCFE; transform: scale(1.001); }

.badge {
    padding: 8px 16px; border-radius: 10px; font-size: 0.85rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 8px; border: none;
}
.badge-success { background: #E6FDF4; color: #05CD99; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-danger { background: #FFEEEE; color: #FF6B6B; }
.badge-warning { background: #FFF9E6; color: #FFB547; }
.badge-secondary { background: #F4F7FE; color: #8F9BBA; }

/* ==========================================
   FORMS & BUTTONS
========================================== */
.form-group { margin-bottom: 24px; width: 100%; }
.form-label { display: block; margin-bottom: 10px; font-weight: 600; color: var(--text-main); font-size: 0.95rem; }
.form-control {
    width: 100%; padding: 16px 20px; border: 2px solid transparent; border-radius: 16px;
    background: var(--background); font-family: inherit; font-size: 1rem; color: var(--text-main);
    transition: var(--transition); box-sizing: border-box; font-weight: 500;
}
.form-control:focus {
    background: var(--surface); outline: none; border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(67, 24, 255, 0.1);
}
.form-control::placeholder { color: #A3AED0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px 28px; border: none; border-radius: 16px;
    font-weight: 600; font-size: 1rem; font-family: inherit;
    cursor: pointer; transition: var(--transition); text-decoration: none;
}
.btn-primary { background: var(--grad-primary); color: white; box-shadow: var(--shadow-btn); }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(67, 24, 255, 0.35); }
.btn-secondary { background: var(--background); color: var(--text-main); }
.btn-secondary:hover { background: #E0E5F2; }
.btn-danger { background: var(--grad-danger); color: white; box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3); }
.btn-danger:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(255, 107, 107, 0.4); }
.btn-success { background: var(--grad-success); color: white; box-shadow: 0 8px 20px rgba(5, 205, 153, 0.3); }
.btn-success:hover { transform: translateY(-3px); }
.btn-outline { background: white; border: 2px solid var(--border); color: var(--text-main); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; border-radius: 12px; }
.btn-icon { padding: 12px; border-radius: 12px; }

/* ==========================================
   DASHBOARD STATS
========================================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; margin-bottom: 40px; }
.stat-card {
    background: white; border-radius: var(--radius-lg); padding: 32px;
    box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 24px;
    border: none; transition: var(--transition);
}
.stat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.stat-icon {
    width: 64px; height: 64px; border-radius: 20px;
    display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.stat-icon.blue { background: var(--grad-primary); color: white; box-shadow: var(--shadow-btn); }
.stat-icon.green { background: var(--grad-success); color: white; box-shadow: 0 8px 20px rgba(5, 205, 153, 0.3); }
.stat-icon.red { background: var(--grad-danger); color: white; box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3); }
.stat-info { flex: 1; }
.stat-number { font-size: 2.2rem; font-weight: 700; color: var(--text-main); line-height: 1; margin-bottom: 8px; }
.stat-label { color: #8F9BBA; font-size: 1rem; font-weight: 600; }

/* ==========================================
   MODALS & LIGHTBOX
========================================== */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 20, 55, 0.6); backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); z-index: 100;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--surface); width: 90%; max-width: 650px;
    border-radius: var(--radius-lg); box-shadow: 0 25px 50px -12px rgba(11, 20, 55, 0.4);
    transform: scale(0.95) translateY(20px); opacity: 0; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; border: none;
}
.modal.show .modal-content { transform: scale(1) translateY(0); opacity: 1; }
.modal-header { padding: 30px 32px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: white; }
.modal-title { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--text-main); }
.modal-close { 
    background: var(--background); border: none; width: 40px; height: 40px; 
    border-radius: 12px; display: flex; align-items: center; justify-content: center; 
    font-size: 1.2rem; color: #8F9BBA; cursor: pointer; transition: var(--transition); 
}
.modal-close:hover { background: #FFEEEE; color: #FF6B6B; transform: rotate(90deg); }
.modal-body { padding: 32px; overflow-y: auto; }

/* ==========================================
   UTILITIES & GRID
========================================== */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; } .gap-4 { gap: 1rem; } .gap-6 { gap: 1.5rem; }
.grid { display: grid; } .grid-2 { grid-template-columns: 1fr 1fr; gap: 24px; } 
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 24px; } .grid-4 { grid-template-columns: repeat(4, 1fr); gap: 24px; }
.w-full { width: 100%; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; } .mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.text-danger { color: #FF6B6B; } .text-success { color: #05CD99; } .text-primary { color: var(--primary); } .text-secondary { color: #8F9BBA; }

.image-item { border-radius: 16px !important; border: none !important; box-shadow: var(--shadow-soft); transition: var(--transition); }
.image-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.autocomplete-list { border-radius: 16px; border: none; box-shadow: var(--shadow-hover); padding: 8px; margin-top: 4px; }
.autocomplete-item { border-radius: 10px; border: none; margin-bottom: 4px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--background); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #A3AED0; }

/* ==========================================
   ENTERPRISE LOGIN & PORTAL UI
========================================== */
.login-wrapper { display: flex; height: 100vh; width: 100vw; overflow: hidden; background: #f8fafc; }
.login-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; background: white; position: relative; z-index: 10; box-shadow: 20px 0 40px rgba(0,0,0,0.05); }
.login-visual-side { flex: 1.2; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; position: relative; overflow: hidden; }
.login-visual-side::before { content: ''; position: absolute; width: 600px; height: 600px; background: radial-gradient(circle, rgba(37,99,235,0.2) 0%, rgba(0,0,0,0) 70%); top: -100px; right: -100px; border-radius: 50%; }
.login-card-modern { width: 100%; max-width: 420px; }

.floating-input { position: relative; margin-bottom: 24px; }
.floating-input input { width: 100%; padding: 16px; padding-right: 45px; border: 2px solid #e2e8f0; border-radius: 12px; background: #f8fafc; font-family: inherit; transition: all 0.3s ease; box-sizing: border-box;}
.floating-input input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(67, 24, 255, 0.1); outline: none; }
.floating-input i { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: #94a3b8; transition: color 0.3s ease; }
.floating-input input:focus + i { color: var(--primary); }

.portal-header { background: linear-gradient(135deg, var(--primary) 0%, #1e3a8a 100%); color: white; padding: 40px; border-radius: 20px; margin-bottom: 30px; box-shadow: 0 10px 25px rgba(67, 24, 255, 0.2); display: flex; justify-content: space-between; align-items: center; }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.dept-card { background: white; border-radius: 16px; padding: 30px; text-align: center; text-decoration: none; color: var(--text-main); border: 1px solid var(--border); transition: var(--transition); display: flex; flex-direction: column; align-items: center; position: relative; overflow: hidden; box-shadow: var(--shadow-soft); }
.dept-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: var(--primary-light); }
.dept-icon { width: 80px; height: 80px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 20px; background: #f1f5f9; color: var(--secondary); transition: var(--transition); }
.dept-card:hover .dept-icon { background: var(--primary); color: white; transform: scale(1.1) rotate(5deg); box-shadow: var(--shadow-btn); }
.dept-card.locked { opacity: 0.6; cursor: not-allowed; filter: grayscale(100%); }
.dept-card.locked:hover { transform: none; box-shadow: var(--shadow-soft); border-color: var(--border); }

/* ==========================================
   SUPER ADMIN CONTROL ROOM UI
========================================== */
.admin-container { max-width: 1400px; margin: 0 auto; }
.admin-top-bar { display: flex; justify-content: space-between; align-items: center; background: white; padding: 20px 30px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); margin-bottom: 30px; border: 1px solid var(--border); }
.admin-top-bar h2 { margin: 0; color: #0f172a; display: flex; align-items: center; gap: 15px; font-size: 24px; }
.admin-top-bar h2 i { background: var(--primary-light); color: var(--primary); padding: 12px; border-radius: 12px; }
.admin-card { background: white; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border: 1px solid var(--border); padding: 24px; margin-bottom: 24px; }

.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.admin-table th { background: #f8fafc; color: #475569; padding: 16px; text-align: right; font-weight: 600; font-size: 14px; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
.admin-table td { padding: 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; color: #334155; }
.admin-table tr:hover td { background: #f8fafc; }

.badge-admin { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: bold; display: inline-block;}
.badge-super { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-dept { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-active { background: #dcfce3; color: #166534; border: 1px solid #bbf7d0; }
.badge-inactive { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ==========================================
   TYPOGRAPHY CONSISTENCY FIX
========================================== */
.sidebar,
.nav-item, 
.nav-submenu .nav-item, 
.sidebar .logo-text,
.btn {
    font-family: 'IBM Plex Sans Arabic', 'Vazirmatn', Tahoma, sans-serif !important;
}

/* Balance the weights so the submenu doesn't look too thin */
.nav-submenu .nav-item {
    font-weight: 500 !important;
    font-size: 14.5px !important;
}

/* Ensure active items are boldly highlighted but use the same font */
.nav-item.active {
    font-weight: 600 !important;
}

/* ==========================================
   CUSTOM SMART DROPDOWN
========================================== */
.custom-dropdown-container {
    position: relative;
    flex: 1; /* Takes up the available space in the row */
}

.custom-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999; /* Ensures it floats above the modal */
    display: none;
    margin-top: 5px;
}

.custom-dropdown-menu.show {
    display: block;
}

.custom-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    font-size: 14.5px;
    font-weight: 500;
}

.custom-dropdown-item:last-child {
    border-bottom: none;
}

.custom-dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    padding-right: 22px; /* Slight slide animation on hover */
}

/* ==========================================
   PRINT MEDIA QUERIES (FOR A4 REPORTS)
========================================== */
@media print {
    /* Hide the sidebar, buttons, and unneeded elements */
    .sidebar, .btn, .modal-close, .nav-dropdown-toggle, form.filter-panel, .filter-card { 
        display: none !important; 
    }
    
    /* Expand the main content to take the full paper width */
    .main-content { 
        margin: 0 !important; 
        padding: 0 !important; 
        width: 100% !important; 
    }

    /* Force browsers to print background colors and gradients */
    * { 
        -webkit-print-color-adjust: exact !important; 
        print-color-adjust: exact !important; 
    }

    /* Remove shadows and floating card styles for flat printing */
    .card, .stat-card { 
        box-shadow: none !important; 
        border: 1px solid #cbd5e1 !important; 
        break-inside: avoid; /* Prevents cards from splitting across two pages */
    }

    /* Modal Printing Logic (For printing single Ifads) */
    body.printing-modal { visibility: hidden; }
    body.printing-modal .modal.show { 
        visibility: visible; 
        position: absolute; 
        left: 0; top: 0; width: 100%; 
        background: white; 
    }
    body.printing-modal .modal-content { 
        box-shadow: none; border: none; width: 100%; max-width: 100%; 
    }
    body.printing-modal .modal-body { visibility: visible; }

    /* Isolate Ifad Section Printing */
    body.printing-ifad-section #general-procurement-section,
    body.printing-ifad-section #divider-line,
    body.printing-ifad-section .page-header {
        display: none !important;
    }
}