/* ===== App Shell (ported from Facilities Management System) ===== */
:root {
    /* Primary Colors - Clean Gray Theme */
    --primary-color: #374151;
    --primary-dark: #1f2937;
    --primary-light: #6b7280;
    /* Accent Color (brand green/teal) */
    --accent-color: #00685E;
    --accent-light: #4FB3A6;
    --accent-dark: #005249;
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #00685E;
    /* 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);
    /* Sidebar */
    --sidebar-width-expanded: 260px;
    --sidebar-width-collapsed: 70px;
    --sidebar-bg: var(--white);
    --sidebar-border: var(--gray-200);
    /* Header */
    --header-height: 60px;
    --header-bg: var(--white);
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-700);
    background: var(--gray-50);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== Layout Structure ===== */
.app-layout { display: flex; min-height: 100vh; }

.app-sidebar {
    position: fixed; top: 0; right: 0; height: 100vh;
    width: var(--sidebar-width-expanded);
    background: var(--sidebar-bg);
    border-left: 1px solid var(--sidebar-border);
    z-index: 1040; display: flex; flex-direction: column;
    transition: width var(--transition-normal); overflow: hidden;
}
.app-sidebar.collapsed { width: var(--sidebar-width-collapsed); }

.app-main {
    flex: 1; margin-right: var(--sidebar-width-expanded);
    display: flex; flex-direction: column; min-height: 100vh;
    transition: margin-right var(--transition-normal);
}
.app-sidebar.collapsed ~ .app-main,
.sidebar-collapsed .app-main { margin-right: var(--sidebar-width-collapsed); }

/* ===== Header ===== */
.app-header {
    height: var(--header-height); background: var(--header-bg);
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; position: sticky; top: 0; z-index: 1020;
}
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-left { display: flex; align-items: center; gap: 1rem; }

.sidebar-toggle {
    width: 38px; height: 38px; border: none; background: var(--gray-100);
    border-radius: var(--radius); color: var(--gray-600); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; transition: all var(--transition-fast);
}
.sidebar-toggle:hover { background: var(--gray-200); color: var(--gray-800); }

.page-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); margin: 0; }

.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.header-btn {
    width: 38px; height: 38px; border: none; background: transparent;
    border-radius: var(--radius); color: var(--gray-500); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; position: relative; transition: all var(--transition-fast);
}
.header-btn:hover { background: var(--gray-100); color: var(--gray-700); }

/* User Menu */
.user-menu {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.4rem 0.75rem; border-radius: var(--radius);
    cursor: pointer; transition: all var(--transition-fast);
}
.user-menu:hover { background: var(--gray-100); }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-color); color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem;
}
.user-info { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-weight: 600; font-size: 0.875rem; color: var(--gray-800); }
.user-role { font-size: 0.75rem; color: var(--gray-500); }

/* ===== Main Content ===== */
.app-content { flex: 1; padding: 1.5rem; }

/* ===== Sidebar Components ===== */
.sidebar-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; gap: 0.75rem; min-height: 60px;
}
.sidebar-logo {
    width: 40px; height: 40px; background: var(--accent-color);
    border-radius: var(--radius); display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.sidebar-logo i { color: var(--white); font-size: 1.2rem; }
.sidebar-brand {
    display: flex; flex-direction: column; overflow: hidden;
    white-space: nowrap; transition: opacity var(--transition-normal);
}
.app-sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }
.sidebar-brand-title { font-size: 0.9rem; font-weight: 700; color: var(--gray-800); line-height: 1.3; }
.sidebar-brand-subtitle { font-size: 0.7rem; color: var(--gray-500); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1rem 0.75rem; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-title {
    font-size: 0.7rem; font-weight: 600; color: var(--gray-400);
    text-transform: uppercase; letter-spacing: 0.05em; padding: 0 0.75rem;
    margin-bottom: 0.5rem; white-space: nowrap; overflow: hidden;
    transition: opacity var(--transition-normal);
}
.app-sidebar.collapsed .nav-section-title { opacity: 0; }

/* Collapsible groups */
.nav-group-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; background: none; border: none; cursor: pointer;
    font: inherit; color: inherit; text-align: inherit;
}
.nav-group-toggle:hover { color: var(--gray-600); }
.nav-group-caret { font-size: 0.65rem; transition: transform var(--transition-normal); }
.nav-group.collapsed .nav-group-caret { transform: rotate(-90deg); }
.nav-group .nav-menu { overflow: hidden; max-height: 500px; transition: max-height var(--transition-normal) ease; }
.nav-group.collapsed .nav-menu { max-height: 0; }
.app-sidebar.collapsed .nav-group-caret { opacity: 0; }

.nav-menu { list-style: none; padding: 0; margin: 0; }
.nav-item { margin-bottom: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.75rem; color: var(--gray-600); text-decoration: none;
    border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
    transition: all var(--transition-fast); white-space: nowrap; overflow: hidden;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-link.active { background: var(--accent-color); color: var(--white); }
.nav-link.active:hover { background: var(--accent-dark); }
.nav-icon {
    width: 22px; min-width: 22px; height: 22px; display: flex;
    align-items: center; justify-content: center; font-size: 1rem;
}
.nav-text { flex: 1; transition: opacity var(--transition-normal); }
.app-sidebar.collapsed .nav-text { opacity: 0; width: 0; }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--gray-100); }
.sidebar-footer-content { display: flex; align-items: center; gap: 0.75rem; overflow: hidden; }
.app-sidebar.collapsed .sidebar-footer-text { opacity: 0; width: 0; }
.sidebar-footer-text { font-size: 0.75rem; color: var(--gray-500); white-space: nowrap; transition: opacity var(--transition-normal); }

/* ===== Overlay ===== */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
    z-index: 1035; opacity: 0; visibility: hidden;
    transition: all var(--transition-normal);
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* ===== Dropdowns ===== */
.dropdown-menu {
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 0.5rem; min-width: 200px;
}
.dropdown-item {
    padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; color: var(--gray-700);
    display: flex; align-items: center; gap: 0.5rem;
}
.dropdown-item:hover { background: var(--gray-100); color: var(--gray-800); }
.dropdown-item i { width: 18px; color: var(--gray-500); }
.dropdown-divider { margin: 0.5rem 0; border-color: var(--gray-200); }

/* ===== Responsive ===== */
@media (max-width: 991px) {
    .app-sidebar { transform: translateX(100%); width: var(--sidebar-width-expanded) !important; }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-right: 0 !important; }
    .user-info { display: none; }
}
@media (max-width: 576px) {
    .app-content { padding: 1rem; }
    .page-title { font-size: 1rem; }
}

/* ===== SweetAlert2 RTL Fix ===== */
.swal2-container { direction: rtl !important; }
.swal2-popup { border-radius: var(--radius-lg) !important; }
.swal2-confirm { background: var(--accent-color) !important; border-radius: var(--radius) !important; }
.swal2-cancel { border-radius: var(--radius) !important; }
