/**
 * Main CSS - Core Styles
 * Colors, Typography, Spacing, Layout
 * 
 * @package FieraManager
 * @version 3.0 - Consolidated
 */

/* ============================================
   CSS VARIABLES - Single Source of Truth
   ============================================ */
:root {
    /* Colors - Grays */
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #64748B;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    /* Colors - Blues */
    --blue-50: #EFF6FF;
    --blue-100: #DBEAFE;
    --blue-200: #BFDBFE;
    --blue-500: #3B82F6;
    --blue-600: #2563EB;
    --blue-700: #1D4ED8;

    /* Colors - Greens */
    --green-100: #D1FAE5;
    --green-500: #10B981;
    --green-600: #059669;
    --green-700: #047857;

    /* Colors - Reds */
    --red-50: #FEF2F2;
    --red-100: #FEE2E2;
    --red-200: #FECACA;
    --red-500: #EF4444;
    --red-600: #DC2626;
    --red-700: #B91C1C;

    /* Colors - Yellows */
    --yellow-50: #FEFCE8;
    --yellow-100: #FEF3C7;
    --yellow-200: #FDE68A;
    --yellow-500: #F59E0B;
    --yellow-600: #CA8A04;
    --yellow-700: #D97706;

    /* Application Colors */
    --color-primary: var(--blue-600);
    --color-success: var(--green-600);
    --color-danger: var(--red-600);
    --color-warning: var(--yellow-600);
    --color-info: var(--blue-600);

    /* UI Colors (Deep Slate / Steel Theme for Max Eye Comfort) */
    --color-background: var(--gray-200);
    --color-surface: var(--gray-100);
    --color-border: var(--gray-300);
    --color-text-primary: var(--gray-900);
    --color-text-secondary: var(--gray-700);

    /* Shadows */
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;

    /* Z-Index */
    --z-dropdown: 1000;
    --z-fixed: 1030;
    --z-modal: 1050;
    --z-tooltip: 1070;
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--color-text-primary);
    background: linear-gradient(135deg, #CBD5E1 0%, #94A3B8 100%) fixed;
    display: flex;
    min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.25;
    color: var(--gray-800);
}

h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
}

h2 {
    font-size: var(--text-xl);
}

h3 {
    font-size: var(--text-lg);
}

h4 {
    font-size: var(--text-base);
}

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

a:hover {
    color: var(--blue-700);
}

/* Links inside colored-background elements inherit white/appropriate color */
a.btn,
a[class*="btn-"],
a[style*="background"],
button a,
.btn a {
    color: inherit;
}
/* Text Utilities */
.text-primary {
    color: var(--color-text-primary);
}

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

.text-success {
    color: var(--color-success);
}

.text-danger {
    color: var(--color-danger);
}

.text-warning {
    color: var(--color-warning);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

/* ============================================
   LAYOUT - SIDEBAR
   ============================================ */
.sidebar {
    width: 260px;
    background: linear-gradient(135deg, #0b1736 0%, #13244f 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: var(--z-fixed);
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: var(--space-6) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--blue-500), #20c997);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #001f3f;
    font-weight: 800;
    font-size: 18px;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.logo-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.8;
    text-transform: uppercase;
}

.nav-links {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-3) var(--space-5);
}

.nav-section {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #ffffff;
    font-weight: 700;
    margin: var(--space-6) var(--space-3) var(--space-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
}
.nav-section:hover {
    background: rgba(255,255,255,0.08);
}
.nav-section::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.55rem;
    transition: transform 0.3s;
    opacity: 0.5;
}
.nav-section.open::after {
    transform: rotate(180deg);
}
.nav-section-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.nav-section-items.open {
    max-height: 600px;
}

.nav-links li {
    margin-bottom: var(--space-1);
}

.nav-links a {
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 11px var(--space-4);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    font-weight: 600;
    transition: background-color var(--transition-fast);
    border: 1px solid transparent;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-links a.active {
    background: rgba(57, 204, 204, 0.15);
    border-color: rgba(57, 204, 204, 0.2);
}

.nav-links a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10%;
    height: 80%;
    width: 4px;
    background: var(--blue-500);
    border-radius: 0 4px 4px 0;
}

/* ============================================
   LAYOUT - MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: var(--space-6) var(--space-8);
    background: var(--color-background);
}

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

.page-title-block {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--gray-800);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

/* ============================================
   SPACING UTILITIES
   ============================================ */
.m-0 {
    margin: 0;
}

.mt-2 {
    margin-top: var(--space-2);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.ml-2 {
    margin-left: var(--space-2);
}

.mr-2 {
    margin-right: var(--space-2);
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.p-4 {
    padding: var(--space-4);
}

.p-6 {
    padding: var(--space-6);
}

.px-4 {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

.py-2 {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
}

.py-4 {
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

.gap-4 {
    gap: var(--space-4);
}

/* ============================================
   FLEX & GRID UTILITIES
   ============================================ */
.flex {
    display: flex;
}

.inline-flex {
    display: inline-flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.flex-1 {
    flex: 1;
}

.grid {
    display: grid;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ============================================
   MOBILE SIDEBAR
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
}

.mobile-menu-btn,
.mobile-close-btn {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

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

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

    .main-content {
        margin-left: 0;
        padding: var(--space-4);
    }

    .mobile-menu-btn,
    .mobile-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: none;
        background: transparent;
        cursor: pointer;
    }
}

/* ============================================
   ADDITIONAL CSS VARIABLES FROM style.css
   ============================================ */
:root {
    /* Legacy Variables - Unified under Deep Slate Theme */
    --primary-color: #1e3a8a;
    --secondary-color: #0EA5E9;
    --accent-color: #6366F1;
    --bg-color: #CBD5E1;
    --card-bg: #E2E8F0;
    --text-primary: #1E293B;
    --text-secondary: #334155;
    --border-color: #94A3B8;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;

    /* Table & UI Surfaces */
    --table-header-bg: #CBD5E1;
    --table-hover-bg: #F0F7FF;
    --input-bg: #E2E8F0;

    /* Font */
    --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Table & Spacing from global-ui.css */
    --table-cell-padding-y: 7px;
    --table-cell-padding-x: 12px;
    --table-header-font-size: 0.7rem;
    --table-body-font-size: 0.8125rem;
    --table-row-min-height: 34px;

    /* Typography - Unified sizes */
    --font-size-base: 0.9375rem;
    --font-size-sm: 0.8125rem;
    --font-size-xs: 0.6875rem;
    --font-size-heading-1: 1.375rem;
    --font-size-heading-2: 1.125rem;
    --font-size-heading-3: 1rem;
    --font-size-heading-4: 0.9375rem;

    /* Spacing Units */
    --spacing-unit: 8px;
    --spacing-xs: 6px;
    --spacing-sm: 10px;
    --spacing-md: 14px;
    --spacing-lg: 18px;
    --spacing-xl: 24px;
    --card-padding: 18px;
    --card-padding-sm: 14px;

    /* Buttons */
    --btn-height: 36px;
    --btn-height-sm: 30px;
    --btn-padding-x: 16px;
    --btn-padding-x-sm: 10px;
    --btn-font-size: 0.8125rem;
    --btn-font-size-sm: 0.75rem;
    --btn-border-radius: 8px;

    /* Legacy Spacing */
    --spacing: 24px;
    --field-height: 54px;
    --border-radius: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
}

/* ============================================
   ANIMATIONS FROM style.css
   ============================================ */
@keyframes fadeIn {
    from { opacity: 1; }
    to { opacity: 1; }
}

.main-content {
    /* animation removed for performance */
}

/* ============================================
   PAGE HEADER COMPONENTS FROM global-ui.css
   ============================================ */
.page-icon-badge {
    display: none;
}

.page-title-block .page-subtitle {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748B;
    margin-top: 1px;
    letter-spacing: 0;
}

/* ============================================
   ENHANCED SIDEBAR STYLES FROM style.css
   ============================================ */
.sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Scrollbar for sidebar */
.nav-links::-webkit-scrollbar {
    width: 4px;
}

.nav-links::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-links a svg {
    width: 18px;
    height: 18px;
    opacity: 1;
    transition: opacity 0.2s;
    stroke-width: 2px;
}

.nav-links a.active svg {
    stroke: var(--secondary-color);
    opacity: 1;
}

.nav-links a.active::before {
    box-shadow: 2px 0 8px rgba(57, 204, 204, 0.4);
}

/* Mobile Close Button */
.mobile-close-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    margin-left: auto;
}

/* ============================================
   FORM CONTROLS FROM style.css
   ============================================ */
.form-control {
    width: 100%;
    height: 42px;
    padding: 0 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: var(--input-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}

.form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.25);
    outline: none;
    background-color: var(--card-bg);
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

/* ============================================
   FORM SECTIONS FROM style.css
   ============================================ */
.form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--gray-100);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 10px;
}

.form-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.form-section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-section-header i,
.form-section-header svg {
    color: var(--secondary-color);
}

/* ============================================
   COMPACT LAYOUT UTILITIES FROM style.css
   ============================================ */
.compact-layout .main-content {
    padding-top: 5px !important;
}

.compact-layout .header {
    margin-bottom: 5px !important;
    padding-bottom: 5px !important;
}

.compact-layout .panel-header {
    padding-bottom: 5px !important;
}

/* ============================================
   HIGH DENSITY FORMS FROM style.css
   ============================================ */
.high-density-form .form-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.high-density-form .form-group {
    margin-bottom: 12px;
}

.high-density-form .form-group.full-width {
    grid-column: span 3;
}

.high-density-form .form-group.span-2 {
    grid-column: span 2;
}

.high-density-form .form-control {
    height: 38px;
    padding: 0 12px;
    font-size: 0.9rem;
    border-radius: 8px;
    border-width: 1px;
}

.high-density-form textarea.form-control {
    height: auto;
    min-height: 80px;
    padding: 10px 12px;
}

.high-density-form .form-label {
    margin-bottom: 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}

.high-density-form .form-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
}

.high-density-form .form-section-header {
    margin-bottom: 12px;
}

.high-density-form .form-section-header h3 {
    font-size: 0.95rem;
}

.high-density-form .modal-actions {
    margin-top: 10px;
    padding-top: 15px;
}

/* ============================================
   GLASSMORPHISM FROM style.css
   ============================================ */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    /* backdrop-filter removed for performance */
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

/* ============================================
   HEADER DIVIDER FROM style.css
   ============================================ */
.header-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
    margin: 20px 0 30px 0;
}

/* ============================================
   UTILITY HELPERS FROM global-ui.css
   ============================================ */
.text-muted {
    color: var(--text-secondary) !important;
    font-size: var(--font-size-sm) !important;
}

.text-sm {
    font-size: var(--font-size-sm) !important;
}

.text-xs {
    font-size: var(--font-size-xs) !important;
}

/* Compact spacing helpers */
.mb-0 {
    margin-bottom: 0 !important;
}

.mb-sm {
    margin-bottom: var(--spacing-sm) !important;
}

.mb-md {
    margin-bottom: var(--spacing-md) !important;
}

.mt-sm {
    margin-top: var(--spacing-sm) !important;
}

.mt-md {
    margin-top: var(--spacing-md) !important;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-sm {
    padding: var(--spacing-sm) !important;
}

.p-md {
    padding: var(--spacing-md) !important;
}

/* Flex helpers */
.d-flex {
    display: flex !important;
}

.align-center {
    align-items: center !important;
}

.justify-between {
    justify-content: space-between !important;
}

.gap-sm {
    gap: var(--spacing-sm) !important;
}

.gap-md {
    gap: var(--spacing-md) !important;
}

/* ============================================
   SECTION TITLE FROM global-ui.css
   ============================================ */
.section-title {
    font-size: var(--font-size-heading-2) !important;
    font-weight: 700 !important;
    color: var(--primary-color) !important;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 14px;
    position: relative;
}

/* ============================================
   PAGE HEADER ROW FROM global-ui.css
   ============================================ */
.page-header-row,
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

/* ============================================
   ADDITIONAL ANIMATIONS
   ============================================ */

.animate-enter {
    /* animation removed for performance */
}

@keyframes slideUp {
    from { opacity: 1; }
    to { opacity: 1; }
}

/* ── ZEIN Special Edition: sidebar header بخلفية بيضاء واللوجو أوضح ── */
.sidebar .sidebar-header {
    background: #ffffff !important;
    border-radius: 12px !important;
    margin: 10px !important;
    padding: 14px 16px !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25) !important;
}
.sidebar .sidebar-header .logo-icon {
    width: 52px !important;
    height: 52px !important;
    background: transparent !important;
    border-radius: 0 !important;
}
.sidebar .sidebar-header .logo-text {
    color: #1e3a8a !important;
    font-weight: 800 !important;
}
.sidebar .sidebar-header .logo-text small {
    color: #2546a6 !important;
    opacity: 0.9 !important;
}
