/* ========================================
   نظام السلامة المهنية - أمريكانا HSE
   تصميم حديث ومتجاوب
   ======================================== */

/* ===== CSS Variables ===== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #aa3636;
    --info-color: #06b6d4;
    --purple-color: #8b5cf6;
    --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;
    --sidebar-width: 280px;
    --transition: all 0.3s ease;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    --text-primary: var(--gray-800);
    --text-secondary: var(--gray-600);
    --text-tertiary: var(--gray-500);
    --border-color: var(--gray-200);
    --card-bg: #ffffff;
    --sidebar-bg: linear-gradient(180deg, #003865 0%, #004C8C 50%, #003865 100%);
    --login-bg: linear-gradient(135deg, #003865 0%, #004C8C 100%);
}

/* ===== Dark Mode Variables ===== */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --text-primary: #f5f5f5;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #3a3a3a;
    --card-bg: #252525;
    --sidebar-bg: linear-gradient(180deg, #001a31 0%, #003865 50%, #001a33 100%);
    --login-bg: linear-gradient(135deg, #001a33 0%, #003865 100%);
    
    /* Adjust shadows for dark mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, 'Arial', 'Helvetica', sans-serif;
    background: var(--login-bg);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    font-weight: 400;
    line-height: 1.6;
}

body.app-active {
    background: var(--bg-secondary);
}

/* Improve text rendering on mobile */
@media (max-width: 768px) {
    html {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    body {
        font-size: 16px;
        line-height: 1.5;
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }
    
    /* Prevent text size adjustment on iOS */
    * {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

.font-cairo {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, 'Arial', 'Helvetica', sans-serif;
}

/* ===== Login Screen ===== */
.login-screen {
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari fix */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--login-bg);
    position: relative;
    overflow: hidden;
    transition: background 0.3s ease;
}

/* Mobile login screen adjustments */
@media (max-width: 480px) {
    .login-screen {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }
    
    .login-container {
        width: 100%;
        max-width: 100%;
    }
}

.login-screen::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: float 20s infinite linear;
    opacity: 0.5;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-50px, -50px) rotate(360deg); }
}

.login-container {
    width: 100%;
    max-width: 420px;
    z-index: 1;
}

.login-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.5s ease;
    transition: background-color 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-wrapper {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 120px;
}

.logo-wrapper img {
    max-width: 180px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    background: transparent;
}

.logo-wrapper img:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.logo-wrapper i {
    display: inline-block;
    padding: 1.5rem;
    background: linear-gradient(135deg, #28408f63 0%, #764ba2 100%);
    border-radius: 50%;
    color: white;
    animation: pulse 2s infinite;
}

[data-theme="dark"] .logo-wrapper i {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

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

/* ===== Form Styles ===== */
.form-input {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.form-input[type="password"] {
    padding-left: 2.5rem;
    padding-right: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

[data-theme="dark"] .form-input:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

/* ===== Password Toggle Button ===== */
.password-toggle-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
    border-radius: 6px;
    z-index: 10;
}

.password-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.password-toggle-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.password-toggle-btn i {
    transition: transform 0.2s ease;
}

.password-toggle-btn:hover i {
    transform: scale(1.1);
}

[data-theme="dark"] .password-toggle-btn {
    color: var(--text-secondary);
}

[data-theme="dark"] .password-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* ===== Buttons ===== */
.btn-primary {
    background: linear-gradient(135deg, #003865 0%, #004C8C 100%);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 56, 101, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #004C8C 0%, #003865 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 56, 101, 0.3);
    color: #ffffff;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 56, 101, 0.25);
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 56, 101, 0.3);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    color: #ffffff;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.875rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

[data-theme="dark"] .btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-light);
    color: var(--primary-light);
}

/* ===== Additional Button Variants ===== */
.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, var(--success-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    color: #ffffff;
}

.btn-success:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #991b1b 100%);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(170, 54, 54, 0.2);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #991b1b 0%, var(--danger-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(170, 54, 54, 0.3);
    color: #ffffff;
}

.btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(170, 54, 54, 0.25);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, var(--warning-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    color: #ffffff;
}

.btn-warning:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #0891b2 100%);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.2);
}

.btn-info:hover {
    background: linear-gradient(135deg, #0891b2 0%, var(--info-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    color: #ffffff;
}

.btn-info:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(6, 182, 212, 0.25);
}

/* Button sizes */
.btn-sm {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

.btn-xs {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    border-radius: 12px;
}

/* ===== Login Error Contact Info ===== */
.login-error-contact {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
}

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

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

.login-error-contact p {
    line-height: 1.6;
}

.login-error-contact a {
    transition: var(--transition);
    word-break: break-word;
}

.login-error-contact a:hover {
    text-decoration: underline;
}

[data-theme="dark"] .login-error-contact {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .login-error-contact p {
    color: var(--text-tertiary);
}

[data-theme="dark"] .login-error-contact a {
    color: var(--primary-light);
}

/* ===== Main App Layout ===== */
.main-app {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

.app-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    margin-right: var(--sidebar-width);
    background: var(--bg-secondary);
    transition: margin-right 0.3s ease;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ===== Sidebar ===== */
/* ألوان شعار الشركة: أزرق (#003865), أحمر (#C8102E), ذهبي (#FFC72C) */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #003865 0%, #004C8C 50%, #003865 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 20px rgba(0, 56, 101, 0.3);
    z-index: 1000;
    right: 0;
    top: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
    border-left: 3px solid #FFC72C;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
}

/* User Profile */
.user-profile {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004C8C 0%, #003865 100%);
    border: 3px solid #FFC72C;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    box-shadow: 0 4px 15px rgba(255, 199, 44, 0.3);
    transition: transform 0.3s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 199, 44, 0.5);
}

.user-info {
    margin-top: 1rem;
}

.user-name {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.user-email {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Navigation */
.navigation {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.3s ease;
    border-right: 4px solid transparent;
    margin: 0.25rem 0.5rem;
    border-radius: 8px 0 0 8px;
    position: relative;
    overflow: hidden;
    min-height: 48px; /* Touch-friendly minimum height */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 199, 44, 0.2);
    user-select: none;
    -webkit-user-select: none;
}

.nav-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: rgba(255, 199, 44, 0.1);
    transition: width 0.3s ease;
}

.nav-item:hover::before,
.nav-item.active::before {
    width: 100%;
}

.nav-item i {
    width: 24px;
    margin-left: 1rem;
    font-size: 1.125rem;
    transition: transform 0.3s ease, color 0.3s ease;
    color: rgba(255, 255, 255, 0.9);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border-right-color: #FFC72C;
    transform: translateX(-3px);
}

.nav-item:hover i {
    transform: scale(1.1);
    color: #FFC72C;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 199, 44, 0.2) 0%, rgba(255, 199, 44, 0.05) 100%);
    color: white;
    border-right-color: #FFC72C;
    font-weight: 600;
    box-shadow: -2px 0 10px rgba(255, 199, 44, 0.3);
}

.nav-item.active i {
    color: #FFC72C;
    transform: scale(1.1);
}

/* Logout Button */
.logout-btn {
    padding: 1rem 1.5rem;
    background: rgba(200, 16, 46, 0.15);
    color: #ffffff;
    border: none;
    border-top: 2px solid rgba(255, 199, 44, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
    margin: 0.5rem;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.logout-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(200, 16, 46, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.logout-btn:hover::before {
    width: 300px;
    height: 300px;
}

.logout-btn i {
    margin-left: 0.75rem;
    position: relative;
    z-index: 1;
}

.logout-btn span {
    position: relative;
    z-index: 1;
}

.logout-btn:hover {
    background: rgba(200, 16, 46, 0.25);
    color: #FFC72C;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    padding: 2rem;
    background: var(--bg-secondary);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    transition: background-color 0.3s ease;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    position: relative;
    margin-right: 0;
    margin-left: 0;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    touch-action: none;
    will-change: opacity;
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Prevent body scroll when sidebar is open on mobile */
@media (max-width: 1024px) {
    body.sidebar-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
    }
    
    body.sidebar-open .app-shell {
        overflow: hidden;
    }
}

.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    right: 0;
    left: 0;
    z-index: 100;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: calc(0.9rem + env(safe-area-inset-top) / 2) 1.25rem;
    padding-top: calc(0.9rem + env(safe-area-inset-top));
    box-shadow: var(--shadow-md);
    align-items: center;
    gap: 1rem;
    min-height: 60px;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #003865 0%, #004C8C 100%);
    color: #ffffff;
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 56, 101, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.sidebar-toggle:active {
    transform: translateY(0) scale(0.95);
}

.sidebar-toggle:focus {
    outline: 2px solid rgba(255, 199, 44, 0.5);
    outline-offset: 2px;
}

.mobile-topbar-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    text-align: right;
}

#mobile-company-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-user-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
}

.mobile-topbar-actions {
    display: none;
    align-items: center;
    gap: 0.75rem;
}

.mobile-icon-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    cursor: pointer;
    transition: var(--transition);
}

.mobile-icon-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mobile-icon-btn:active {
    transform: translateY(0) scale(0.95);
}

.mobile-icon-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.mobile-icon-btn.has-notifications {
    color: var(--danger-color);
    border-color: rgba(200, 16, 46, 0.35);
}

.header-notifications-btn.has-notifications,
.notifications-btn.has-notifications {
    color: var(--danger-color);
}

.mobile-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--danger-color);
    color: white;
    border-radius: 9999px;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Body scroll lock handled in media query below */

.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.section-header {
    margin-bottom: 2rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Navigation Icons Container */
.navigation-icons-container {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    display: flex !important;
    gap: 0.5rem;
    align-items: center;
    z-index: 1000 !important;
    flex-shrink: 0;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Main Menu Icon (القائمة الرئيسية) */
.main-menu-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    border: none;
    font-size: 1.25rem;
    flex-shrink: 0;
    position: relative;
}

.main-menu-icon i {
    font-size: 1.25rem;
}

.main-menu-icon:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.main-menu-icon:active {
    transform: translateY(0) scale(0.95);
    box-shadow: var(--shadow-sm);
}

.main-menu-icon:focus {
    outline: 2px solid rgba(37, 99, 235, 0.5);
    outline-offset: 2px;
}

[data-theme="dark"] .main-menu-icon {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
}

[data-theme="dark"] .main-menu-icon:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

/* Back Menu Icon (العودة للقائمة السابقة) */
.back-menu-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    font-size: 1.25rem;
    flex-shrink: 0;
    position: relative;
}

.back-menu-icon i {
    font-size: 1.25rem;
}

.back-menu-icon:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.back-menu-icon:active {
    transform: translateY(0) scale(0.95);
    box-shadow: var(--shadow-sm);
}

.back-menu-icon:focus {
    outline: 2px solid rgba(37, 99, 235, 0.5);
    outline-offset: 2px;
}

[data-theme="dark"] .back-menu-icon {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .back-menu-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-light);
}

/* Back/Home Icon Button (Legacy - للتوافق مع الكود القديم) */
.back-home-icon {
    position: absolute;
    right: 0;
    top: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    border: none;
    z-index: 10;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.back-home-icon i {
    font-size: 1.25rem;
}

.back-home-icon:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.back-home-icon:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .back-home-icon {
    background: var(--primary-light);
}

[data-theme="dark"] .back-home-icon:hover {
    background: var(--primary-color);
}

/* Responsive Back Icon */
@media (max-width: 768px) {
    .back-home-icon {
        width: 44px;
        height: 44px;
        font-size: 1.125rem;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    .back-home-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    .section-header {
        padding-right: 0;
    }
}

/* Adjust section-title when navigation icons are present */
.section-header:has(.navigation-icons-container) .section-title,
.section-header:has(.back-home-icon) .section-title {
    padding-right: 110px; /* مساحة لاثنين من الأيقونات + الفجوة */
}

@media (max-width: 768px) {
    .section-header:has(.navigation-icons-container) .section-title,
    .section-header:has(.back-home-icon) .section-title {
        padding-right: 104px;
    }
    
    .main-menu-icon,
    .back-menu-icon {
        width: 44px;
        height: 44px;
        font-size: 1.125rem;
        border-radius: 10px;
    }
}

@media (max-width: 480px) {
    .section-header:has(.navigation-icons-container) .section-title,
    .section-header:has(.back-home-icon) .section-title {
        padding-right: 98px;
    }
    
    .main-menu-icon,
    .back-menu-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    .navigation-icons-container {
        gap: 0.375rem;
    }
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    letter-spacing: -0.01em;
}

[data-theme="dark"] .section-title {
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    transition: color 0.3s ease;
    margin-top: 0.25rem;
    line-height: 1.5;
    font-weight: 500;
}

[data-theme="dark"] .section-subtitle {
    color: var(--text-secondary);
}

/* Responsive section titles */
@media (max-width: 768px) {
    .section-title {
        font-size: 1.5rem;
        line-height: 1.4;
    }
    
    .section-subtitle {
        font-size: 0.9375rem;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .section-title {
        font-size: 1.375rem;
        line-height: 1.4;
    }
    
    .section-subtitle {
        font-size: 0.875rem;
        line-height: 1.5;
    }
}

.section-content {
    padding: 1.5rem 0;
    animation: fadeIn 0.3s ease;
}

.section-content .content-card {
    margin-bottom: 1.5rem;
}

.section-content .content-card:last-child {
    margin-bottom: 0;
}

.section-subtitle:lang(en) {
    color: #2563eb;
    font-weight: 500;
}

/* ===== KPI Cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Base KPI Card Style - Applies to all kpi-card elements */
.kpi-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

/* Override for cards with kpi- prefix classes (kpi-danger, kpi-success, etc.) */
/* These have higher specificity and will override the legacy styles below */

/* Subtle background colors for each KPI card type */
.kpi-card.kpi-primary {
    background: linear-gradient(135deg, rgba(0, 56, 101, 0.03) 0%, rgba(0, 76, 140, 0.05) 100%);
}
.kpi-card.kpi-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.03) 0%, rgba(5, 150, 105, 0.05) 100%);
}
.kpi-card.kpi-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.03) 0%, rgba(217, 119, 6, 0.05) 100%);
}
.kpi-card.kpi-info {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.03) 0%, rgba(8, 145, 178, 0.05) 100%);
}
.kpi-card.kpi-danger {
    background: linear-gradient(135deg, rgba(170, 54, 54, 0.03) 0%, rgba(153, 27, 27, 0.05) 100%);
}
.kpi-card.kpi-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.03) 0%, rgba(124, 58, 237, 0.05) 100%);
}

[data-theme="dark"] .kpi-card.kpi-primary {
    background: linear-gradient(135deg, rgba(0, 56, 101, 0.15) 0%, rgba(0, 76, 140, 0.2) 100%);
}
[data-theme="dark"] .kpi-card.kpi-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.2) 100%);
}
[data-theme="dark"] .kpi-card.kpi-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.2) 100%);
}
[data-theme="dark"] .kpi-card.kpi-info {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(8, 145, 178, 0.2) 100%);
}
[data-theme="dark"] .kpi-card.kpi-danger {
    background: linear-gradient(135deg, rgba(170, 54, 54, 0.15) 0%, rgba(153, 27, 27, 0.2) 100%);
}
[data-theme="dark"] .kpi-card.kpi-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(124, 58, 237, 0.2) 100%);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background: var(--primary-color);
    z-index: 1;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

/* KPI Card Color Variants - Border */
.kpi-card.kpi-primary::before { 
    background: linear-gradient(180deg, #003865 0%, #004C8C 100%);
    width: 5px;
    box-shadow: 0 0 10px rgba(0, 56, 101, 0.3);
}
.kpi-card.kpi-primary:hover {
    border-color: #003865;
    box-shadow: 0 8px 20px rgba(0, 56, 101, 0.25);
}

.kpi-card.kpi-success::before { 
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    width: 5px;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}
.kpi-card.kpi-success:hover {
    border-color: #10b981;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.25);
}

.kpi-card.kpi-warning::before { 
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    width: 5px;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}
.kpi-card.kpi-warning:hover {
    border-color: #f59e0b;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.25);
}

.kpi-card.kpi-info::before { 
    background: linear-gradient(180deg, #06b6d4 0%, #0891b2 100%);
    width: 5px;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}
.kpi-card.kpi-info:hover {
    border-color: #06b6d4;
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.25);
}

.kpi-card.kpi-danger::before { 
    background: linear-gradient(180deg, #aa3636 0%, #991b1b 100%);
    width: 5px;
    box-shadow: 0 0 10px rgba(170, 54, 54, 0.3);
}
.kpi-card.kpi-danger:hover {
    border-color: #aa3636;
    box-shadow: 0 8px 20px rgba(170, 54, 54, 0.25);
}

.kpi-card.kpi-purple::before { 
    background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
    width: 5px;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}
.kpi-card.kpi-purple:hover {
    border-color: #8b5cf6;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.25);
}

.kpi-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem;
    font-size: 1.75rem;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover .kpi-icon {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* KPI Icon Colors */
.kpi-primary .kpi-icon { 
    background: linear-gradient(135deg, #003865 0%, #004C8C 100%);
    box-shadow: 0 4px 15px rgba(0, 56, 101, 0.3);
}
.kpi-success .kpi-icon { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.kpi-warning .kpi-icon { 
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.kpi-info .kpi-icon { 
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}
.kpi-danger .kpi-icon { 
    background: linear-gradient(135deg, #aa3636 0%, #991b1b 100%);
    box-shadow: 0 4px 15px rgba(170, 54, 54, 0.3);
}
.kpi-purple .kpi-icon { 
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.kpi-content {
    flex: 1;
    position: relative;
    z-index: 2;
}

.kpi-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    line-height: 1.4;
}

/* KPI Label Colors by Type */
.kpi-primary .kpi-label {
    color: #003865;
    font-weight: 700;
}
.kpi-success .kpi-label {
    color: #059669;
    font-weight: 700;
}
.kpi-warning .kpi-label {
    color: #d97706;
    font-weight: 700;
}
.kpi-info .kpi-label {
    color: #0891b2;
    font-weight: 700;
}
.kpi-danger .kpi-label {
    color: #aa3636;
    font-weight: 700;
}
.kpi-purple .kpi-label {
    color: #7c3aed;
    font-weight: 700;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Cairo', sans-serif;
}

/* KPI Value Colors by Type */
.kpi-primary .kpi-value {
    color: #003865;
    text-shadow: 0 2px 6px rgba(0, 56, 101, 0.2);
}
.kpi-success .kpi-value {
    color: #059669;
    text-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}
.kpi-warning .kpi-value {
    color: #d97706;
    text-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}
.kpi-info .kpi-value {
    color: #0891b2;
    text-shadow: 0 2px 6px rgba(6, 182, 212, 0.2);
}
.kpi-danger .kpi-value {
    color: #aa3636;
    text-shadow: 0 2px 6px rgba(170, 54, 54, 0.2);
}
.kpi-purple .kpi-value {
    color: #7c3aed;
    text-shadow: 0 2px 6px rgba(139, 92, 246, 0.2);
}

.kpi-description {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    transition: color 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    margin-top: 0.25rem;
}

/* KPI Description Colors by Type */
.kpi-primary .kpi-description {
    color: #4b5563;
    font-weight: 600;
}
.kpi-success .kpi-description {
    color: #4b5563;
    font-weight: 600;
}
.kpi-warning .kpi-description {
    color: #4b5563;
    font-weight: 600;
}
.kpi-info .kpi-description {
    color: #4b5563;
    font-weight: 600;
}
.kpi-danger .kpi-description {
    color: #4b5563;
    font-weight: 600;
}
.kpi-purple .kpi-description {
    color: #4b5563;
    font-weight: 600;
}

/* Dark Mode Adjustments */
[data-theme="dark"] .kpi-label {
    color: var(--text-secondary);
}
[data-theme="dark"] .kpi-primary .kpi-label {
    color: #60a5fa;
}
[data-theme="dark"] .kpi-success .kpi-label {
    color: #34d399;
}
[data-theme="dark"] .kpi-warning .kpi-label {
    color: #fbbf24;
}
[data-theme="dark"] .kpi-info .kpi-label {
    color: #22d3ee;
}
[data-theme="dark"] .kpi-danger .kpi-label {
    color: #f87171;
}
[data-theme="dark"] .kpi-purple .kpi-label {
    color: #a78bfa;
}

[data-theme="dark"] .kpi-value {
    color: var(--text-primary);
}
[data-theme="dark"] .kpi-primary .kpi-value {
    color: #60a5fa;
}
[data-theme="dark"] .kpi-success .kpi-value {
    color: #34d399;
}
[data-theme="dark"] .kpi-warning .kpi-value {
    color: #fbbf24;
}
[data-theme="dark"] .kpi-info .kpi-value {
    color: #22d3ee;
}
[data-theme="dark"] .kpi-danger .kpi-value {
    color: #f87171;
}
[data-theme="dark"] .kpi-purple .kpi-value {
    color: #a78bfa;
}

[data-theme="dark"] .kpi-description {
    color: var(--text-tertiary);
}

/* Safety Metrics Cards - Enhanced styling to match previous design */
/* These styles override the base kpi-card styles for safety metrics cards */
.kpi-card.kpi-danger {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
}

.kpi-card.kpi-warning {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid #fed7aa;
    border-radius: 0.5rem;
}

.kpi-card.kpi-info {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
}

.kpi-card.kpi-purple {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border: 1px solid #ddd6fe;
    border-radius: 0.5rem;
}

/* Override kpi-card default styles for safety metrics cards */
.kpi-card.kpi-danger::before,
.kpi-card.kpi-warning::before,
.kpi-card.kpi-info::before,
.kpi-card.kpi-purple::before {
    display: none;
}

.kpi-card.kpi-danger::after,
.kpi-card.kpi-warning::after,
.kpi-card.kpi-info::after,
.kpi-card.kpi-purple::after {
    display: none;
}

[data-theme="dark"] .kpi-card.kpi-danger {
    background: linear-gradient(135deg, rgba(127, 29, 29, 0.2) 0%, rgba(153, 27, 27, 0.25) 100%);
    border: 1px solid rgba(185, 28, 28, 0.3);
}

[data-theme="dark"] .kpi-card.kpi-warning {
    background: linear-gradient(135deg, rgba(146, 64, 14, 0.2) 0%, rgba(154, 52, 18, 0.25) 100%);
    border: 1px solid rgba(217, 119, 6, 0.3);
}

[data-theme="dark"] .kpi-card.kpi-info {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.2) 0%, rgba(29, 78, 216, 0.25) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .kpi-card.kpi-purple {
    background: linear-gradient(135deg, rgba(107, 33, 168, 0.2) 0%, rgba(124, 58, 237, 0.25) 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Clinic Cards - Enhanced styling */
.content-card .w-12.h-12.rounded-xl {
    transition: all 0.3s ease;
}

.content-card:hover .w-12.h-12.rounded-xl {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== Content Cards ===== */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.content-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
}

.card-body {
    padding: 1.5rem;
}

/* ===== Activity List ===== */
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.activity-item:hover {
    background: var(--bg-tertiary);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem;
    font-size: 1rem;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}

.activity-time {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    transition: color 0.3s ease;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    text-align: center;
    transition: background-color 0.3s ease;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-content .stat-value {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.stat-content .stat-label {
    font-size: 0.875rem;
    margin-bottom: 0;
}

/* ===== Stats Cards Grid (Reports Widget) ===== */
.stats-cards-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
}

@media (min-width: 480px) {
    .stats-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .stats-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .stats-cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Stat Card Styles for Reports Widget - Scoped to stats-cards-grid */
.stats-cards-grid .stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    min-height: 140px;
    position: relative;
    overflow: hidden;
    gap: 0;
}

.stats-cards-grid .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    transition: height 0.3s ease;
}

.stats-cards-grid .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stats-cards-grid .stat-card:hover::before {
    height: 6px;
}

.stats-cards-grid .stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.stats-cards-grid .stat-card:hover .stat-card-icon {
    transform: scale(1.1);
}

.stats-cards-grid .stat-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.stats-cards-grid .stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.stats-cards-grid .stat-card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
}

/* Stat Card Color Variants */
.stats-cards-grid .stat-card-red {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-color: rgba(239, 68, 68, 0.2);
}

.stats-cards-grid .stat-card-red::before {
    background: #ef4444;
}

.stats-cards-grid .stat-card-red .stat-card-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.stats-cards-grid .stat-card-red .stat-card-value {
    color: #dc2626;
}

.stats-cards-grid .stat-card-blue {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-color: rgba(59, 130, 246, 0.2);
}

.stats-cards-grid .stat-card-blue::before {
    background: #3b82f6;
}

.stats-cards-grid .stat-card-blue .stat-card-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.stats-cards-grid .stat-card-blue .stat-card-value {
    color: #2563eb;
}

.stats-cards-grid .stat-card-green {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
    border-color: rgba(34, 197, 94, 0.2);
}

.stats-cards-grid .stat-card-green::before {
    background: #22c55e;
}

.stats-cards-grid .stat-card-green .stat-card-icon {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.stats-cards-grid .stat-card-green .stat-card-value {
    color: #16a34a;
}

.stats-cards-grid .stat-card-yellow {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(234, 179, 8, 0.05) 100%);
    border-color: rgba(234, 179, 8, 0.2);
}

.stats-cards-grid .stat-card-yellow::before {
    background: #eab308;
}

.stats-cards-grid .stat-card-yellow .stat-card-icon {
    background: rgba(234, 179, 8, 0.15);
    color: #ca8a04;
}

.stats-cards-grid .stat-card-yellow .stat-card-value {
    color: #ca8a04;
}

.stats-cards-grid .stat-card-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-color: rgba(139, 92, 246, 0.2);
}

.stats-cards-grid .stat-card-purple::before {
    background: #8b5cf6;
}

.stats-cards-grid .stat-card-purple .stat-card-icon {
    background: rgba(139, 92, 246, 0.15);
    color: #7c3aed;
}

.stats-cards-grid .stat-card-purple .stat-card-value {
    color: #7c3aed;
}

/* Dark Mode Adjustments */
[data-theme="dark"] .stats-cards-grid .stat-card-red {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.08) 100%);
    border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .stats-cards-grid .stat-card-blue {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%);
    border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .stats-cards-grid .stat-card-green {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.08) 100%);
    border-color: rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .stats-cards-grid .stat-card-yellow {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(234, 179, 8, 0.08) 100%);
    border-color: rgba(234, 179, 8, 0.3);
}

[data-theme="dark"] .stats-cards-grid .stat-card-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(139, 92, 246, 0.3);
}

/* Responsive Adjustments for Stat Cards */
@media (max-width: 480px) {
    .stats-cards-grid .stat-card {
        padding: 1rem;
        min-height: 120px;
    }
    
    .stats-cards-grid .stat-card-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .stats-cards-grid .stat-card-value {
        font-size: 1.75rem;
    }
    
    .stats-cards-grid .stat-card-label {
        font-size: 0.8125rem;
    }
}

/* ===== Tabs ===== */
.tabs-container {
    margin-bottom: 1.5rem;
}

.tabs-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: thin;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: 12px 12px 0 0;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    padding: 0.875rem 1.75rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    font-family: 'Cairo', sans-serif;
    border-radius: 8px 8px 0 0;
    position: relative;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-tertiary);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.tab-btn.active::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
}

.tab-btn i {
    margin-left: 0.5rem;
    font-size: 0.875rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* تحسينات خاصة لتبويبات قسم الطوارئ */
#emergency-section .tabs-nav {
    margin-bottom: 0;
}

#emergency-section .tab-content {
    padding-top: 1.5rem;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

/* ===== Notifications ===== */
.notification-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 450px;
    width: calc(100vw - 2.5rem);
}

.notification {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    min-width: 300px;
    max-width: 100%;
    border-right: 4px solid;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(-100px);
    position: relative;
    overflow: hidden;
}

.notification.notification-visible {
    opacity: 1;
    transform: translateX(0);
    animation: slideInLeft 0.3s ease;
}

.notification.notification-dismissing {
    animation: slideOutLeft 0.3s ease;
    opacity: 0;
    transform: translateX(-100px);
}

/* ألوان الحدود حسب النوع */
.notification.notification-success { 
    border-right-color: var(--success-color);
    background: linear-gradient(to left, rgba(34, 197, 94, 0.05), var(--card-bg));
}

.notification.notification-error { 
    border-right-color: var(--danger-color);
    background: linear-gradient(to left, rgba(239, 68, 68, 0.05), var(--card-bg));
}

.notification.notification-warning { 
    border-right-color: var(--warning-color);
    background: linear-gradient(to left, rgba(234, 179, 8, 0.05), var(--card-bg));
}

.notification.notification-info { 
    border-right-color: var(--info-color);
    background: linear-gradient(to left, rgba(59, 130, 246, 0.05), var(--card-bg));
}

.notification.notification-emergency { 
    border-right-color: #dc2626;
    background: linear-gradient(to left, rgba(220, 38, 38, 0.1), var(--card-bg));
    border-right-width: 6px;
}

/* تأثير النبض للتنبيهات الحرجة */
.notification-critical-pulse {
    animation: criticalPulse 2s ease-in-out infinite;
}

@keyframes criticalPulse {
    0%, 100% {
        box-shadow: var(--shadow-xl);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2), var(--shadow-xl);
    }
}

/* الأولويات */
.notification-priority-critical {
    border-right-width: 6px;
    box-shadow: 0 10px 25px rgba(220, 38, 38, 0.3);
}

.notification-priority-high {
    border-right-width: 5px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* أيقونة الإشعار */
.notification-icon-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
}

.notification-icon {
    font-size: 1.5rem;
}

.notification.notification-success .notification-icon-wrapper {
    background: rgba(34, 197, 94, 0.1);
}

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

.notification.notification-error .notification-icon-wrapper {
    background: rgba(239, 68, 68, 0.1);
}

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

.notification.notification-warning .notification-icon-wrapper {
    background: rgba(234, 179, 8, 0.1);
}

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

.notification.notification-info .notification-icon-wrapper {
    background: rgba(59, 130, 246, 0.1);
}

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

.notification.notification-emergency .notification-icon-wrapper {
    background: rgba(220, 38, 38, 0.15);
    animation: iconPulse 1.5s ease-in-out infinite;
}

.notification.notification-emergency .notification-icon { 
    color: #dc2626;
    font-size: 1.75rem;
}

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

/* محتوى الإشعار */
.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.notification-message {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.notification-description {
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.5rem;
}

/* أزرار الإشعار */
.notification-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.notification-action {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.notification-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.notification-action-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.notification-action-primary:hover {
    background: var(--primary-color-dark, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.notification-action-secondary {
    background: transparent;
}

.notification-action-secondary:hover {
    background: var(--bg-secondary);
}

/* زر الإغلاق */
.notification-close {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* تأثيرات الحركة */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100px);
    }
}

/* تحسينات للشاشات الصغيرة */
@media (max-width: 640px) {
    .notification-container {
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
    }
    
    .notification {
        min-width: auto;
        padding: 1rem;
    }
    
    .notification-actions {
        flex-direction: column;
    }
    
    .notification-action {
        width: 100%;
    }
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    text-align: center;
    color: white;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 350px;
}

.loading-spinner i {
    color: #3b82f6;
    margin-bottom: 20px;
}

.loading-spinner .loading-message {
    color: #1f2937;
    font-weight: 600;
    font-size: 16px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.loading-progress-bar {
    width: 100%;
    max-width: 300px;
    height: 10px;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 5px;
    margin: 20px auto 10px;
    overflow: hidden;
    position: relative;
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2563eb, #1d4ed8);
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
    position: relative;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.loading-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.loading-progress-text {
    text-align: center;
    color: #3b82f6;
    font-weight: bold;
    font-size: 20px;
    margin-top: 10px;
    font-family: 'Cairo', sans-serif;
}

/* ===== Improved Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card {
    animation: fadeInUp 0.5s ease backwards;
}

.kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.2s; }
.kpi-card:nth-child(4) { animation-delay: 0.3s; }

.content-card {
    animation: fadeInUp 0.5s ease 0.2s backwards;
}

/* ===== Enhanced Hover Effects ===== */
.nav-item {
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1));
    transition: width 0.3s ease;
}

.nav-item:hover::before {
    width: 100%;
}

/* ===== Improved Card Shadows ===== */
.kpi-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-xl);
}

.content-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* ===== Responsive Design ===== */

/* ===== Large Tablets and Small Desktops (768px - 1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .app-shell {
        margin-right: 0 !important;
        width: 100%;
    }

    .sidebar {
        width: 280px;
        max-width: 85vw;
        transform: translateX(100%);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-topbar {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .sidebar-toggle {
        display: inline-flex;
        z-index: 101;
    }
    
    .mobile-topbar-actions {
        display: flex;
    }
    
    .main-content {
        padding: calc(4.75rem + env(safe-area-inset-top)) 1.5rem 2rem;
        width: 100%;
        margin-right: 0;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
    
    .theme-toggle {
        display: none;
    }
    
    #company-logo-header {
        display: none !important;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
}

/* ===== Tablets Portrait (481px - 768px) ===== */
@media (max-width: 768px) and (min-width: 481px) {
    .app-shell {
        margin-right: 0 !important;
        width: 100%;
    }

    .sidebar {
        width: 280px;
        max-width: 80vw;
        transform: translateX(100%);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-topbar {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .sidebar-toggle {
        display: inline-flex;
        width: 44px;
        height: 44px;
        z-index: 101;
    }
    
    .mobile-topbar-actions {
        display: flex;
    }
    
    .main-content {
        padding: calc(4.5rem + env(safe-area-inset-top)) 1.25rem 1.75rem;
        width: 100%;
        margin-right: 0;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .theme-toggle {
        display: none;
    }
    
    #company-logo-header {
        display: none !important;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .section-subtitle {
        font-size: 0.95rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    .kpi-value {
        font-size: 1.75rem;
    }
    
    .kpi-icon {
        width: 55px;
        height: 55px;
        font-size: 1.375rem;
    }
    
    /* Tables - Enable horizontal scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    
    .table-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 20px;
        height: 100%;
        background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .data-table {
        min-width: 600px;
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Forms - Stack vertically */
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    
    /* Buttons - Touch friendly */
    .btn-primary,
    .btn-secondary {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
    
    /* Login form buttons should be full width on mobile */
    .login-card .btn-primary,
    .login-card .btn-secondary {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Modals */
    .modal-content {
        max-width: 95vw;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1.25rem;
    }
}

/* ===== Mobile Phones Landscape (481px - 768px landscape) ===== */
@media (max-width: 768px) and (min-width: 481px) and (orientation: landscape) {
    .main-content {
        padding: calc(3.5rem + env(safe-area-inset-top)) 1.25rem 1.5rem;
    }
    
    .mobile-topbar {
        padding: calc(0.75rem + env(safe-area-inset-top) / 2) 1.25rem;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.875rem;
    }
    
    .kpi-card {
        padding: 1.25rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
}

/* ===== Mobile Phones Portrait (320px - 480px) ===== */
@media (max-width: 480px) {
    .app-shell {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }

    .sidebar {
        width: 85%;
        max-width: 320px;
        min-width: 280px;
        right: 0 !important;
        left: auto !important;
        transform: translateX(100%);
        z-index: 1000;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    .mobile-topbar {
        display: flex;
        padding: calc(0.8rem + env(safe-area-inset-top) / 2) 1rem;
        padding-top: calc(0.8rem + env(safe-area-inset-top));
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
    }
    
    .sidebar-toggle {
        display: inline-flex;
        width: 44px;
        height: 44px;
        border-radius: 10px;
        z-index: 101;
        flex-shrink: 0;
    }
    
    .mobile-topbar-actions {
        display: flex;
        flex-shrink: 0;
    }
    
    .mobile-icon-btn {
        width: 44px;
        height: 44px;
        border-radius: 10px;
        flex-shrink: 0;
    }
    
    .main-content {
        padding: calc(4.5rem + env(safe-area-inset-top)) 1rem 1.5rem;
        width: 100%;
        margin-right: 0;
        overflow-x: hidden;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .theme-toggle {
        display: none;
    }
    
    #company-logo-header {
        display: none !important;
    }
    
    /* تحسين عرض القائمة الجانبية على الموبايل */
    .sidebar {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    .navigation {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* منع التمرير الأفقي غير المرغوب فيه */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        position: relative;
        max-width: 100vw;
    }
    
    .main-app,
    .app-shell,
    .main-content {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* منع التمرير الأفقي في جميع العناصر */
    img, video, iframe, embed, object {
        max-width: 100%;
        height: auto;
    }
    
    /* تحسين عرض الجداول */
    .table-wrapper {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Typography */
    .section-title {
        font-size: 1.375rem;
        margin-bottom: 0.75rem;
    }
    
    .section-subtitle {
        font-size: 0.875rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .kpi-value {
        font-size: 1.75rem;
    }
    
    .kpi-label {
        font-size: 0.8125rem;
    }
    
    .kpi-description {
        font-size: 0.6875rem;
    }
    
    .kpi-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
        margin-left: 0.75rem;
    }
    
    .kpi-card {
        padding: 1.25rem;
    }
    
    /* Login Screen */
    .login-card {
        padding: 2rem 1.5rem;
        margin: 1rem;
        border-radius: 16px;
    }
    
    .login-container {
        padding: 0;
    }
    
    #login-title {
        font-size: 1.5rem;
    }
    
    /* Tables - Full width horizontal scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
        position: relative;
    }
    
    .table-wrapper::before,
    .table-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px;
        pointer-events: none;
        z-index: 1;
    }
    
    .table-wrapper::before {
        right: 0;
        background: linear-gradient(to right, var(--bg-secondary), transparent);
    }
    
    .table-wrapper::after {
        left: 0;
        background: linear-gradient(to left, var(--bg-secondary), transparent);
    }
    
    .data-table {
        min-width: 100%;
        font-size: 0.8125rem;
        border-radius: 0;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
        white-space: nowrap;
        font-size: 0.8125rem;
    }
    
    .data-table th {
        font-size: 0.75rem;
        padding: 0.75rem 0.5rem;
    }
    
    /* Forms - Full vertical stack */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    /* Form inputs - Touch friendly */
    .form-input {
        min-height: 44px;
        padding: 0.875rem 1rem;
        font-size: 1rem;
        -webkit-appearance: none;
        appearance: none;
    }
    
    textarea.form-input {
        min-height: 100px;
    }
    
    /* Buttons - Touch friendly minimum size */
    .btn-primary,
    .btn-secondary,
    .btn-icon-primary,
    .btn-icon-danger,
    .btn-icon-success,
    .btn-icon-info {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
        touch-action: manipulation;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 0.625rem 1rem;
        font-size: 0.9375rem;
    }
    
    /* Cards */
    .content-card {
        border-radius: 12px;
    }
    
    .card-header {
        padding: 1.25rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    /* Modals - Full screen on mobile */
    .modal-content {
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .modal-header {
        padding: 1.25rem;
        flex-shrink: 0;
    }
    
    .modal-body {
        padding: 1.25rem;
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        padding: 1.25rem;
        flex-shrink: 0;
        border-top: 1px solid var(--border-color);
    }
    
    .modal-close {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Navigation items - Touch friendly */
    .nav-item {
        padding: 1rem 1.25rem;
        min-height: 48px;
    }
    
    /* User profile in sidebar */
    .user-profile {
        padding: 1.5rem 1.25rem;
    }
    
    .user-avatar {
        width: 70px;
        height: 70px;
        font-size: 1.75rem;
    }
    
    .user-name {
        font-size: 1rem;
    }
    
    .user-email {
        font-size: 0.8125rem;
    }
    
    /* Logout button */
    .logout-btn {
        padding: 1rem 1.25rem;
        min-height: 48px;
        margin: 0.5rem;
    }
    
    /* Mobile topbar title */
    #mobile-company-name {
        font-size: 0.9375rem;
    }
    
    .mobile-user-name {
        font-size: 0.6875rem;
    }
    
    /* Activity list */
    .activity-item {
        padding: 0.875rem;
    }
    
    .activity-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9375rem;
    }
    
    /* Notifications */
    .notification {
        min-width: auto;
        max-width: calc(100vw - 2rem);
        padding: 1rem;
    }
    
    /* Section header */
    .section-header {
        margin-bottom: 1.5rem;
    }
    
    /* PTW Form sections */
    .ptw-form-section {
        padding: 1.25rem;
    }
    
    .ptw-checklist-grid {
        grid-template-columns: 1fr;
    }
    
    /* Stats */
    .stat-item {
        padding: 0.875rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.8125rem;
    }
}

/* ===== Very Small Phones (max-width: 360px) ===== */
@media (max-width: 360px) {
    .main-content {
        padding: calc(4rem + env(safe-area-inset-top)) 0.875rem 1.25rem;
    }
    
    .mobile-topbar {
        padding: calc(0.75rem + env(safe-area-inset-top) / 2) 0.875rem;
    }
    
    .sidebar {
        max-width: 100%;
    }
    
    .kpi-card {
        padding: 1rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.25rem;
    }
    
    .card-title {
        font-size: 0.9375rem;
    }
    
    .login-card {
        padding: 1.75rem 1.25rem;
    }
    
    #login-title {
        font-size: 1.375rem;
    }
}

/* ===== Desktop - Hide mobile elements ===== */
@media (min-width: 1025px) {
    .sidebar-overlay {
        display: none !important;
    }
    
    .mobile-topbar {
        display: none !important;
    }
    
    .sidebar-toggle {
        display: none !important;
    }
    
    .mobile-topbar-actions {
        display: none !important;
    }
    
    /* إعادة تعيين القائمة الجانبية على سطح المكتب */
    .sidebar {
        transform: translateX(0) !important;
        position: fixed;
        z-index: 100;
    }
    
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    body.sidebar-open {
        overflow: auto !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
    }
}

/* ===== Landscape Orientation Adjustments ===== */
@media (max-width: 1024px) and (orientation: landscape) {
    .main-content {
        padding-top: calc(3.5rem + env(safe-area-inset-top));
    }
    
    .mobile-topbar {
        padding: calc(0.75rem + env(safe-area-inset-top) / 2) 1.25rem;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ===== Print Styles ===== */
@media print {
    .sidebar,
    .mobile-topbar,
    .sidebar-toggle,
    .theme-toggle,
    .notifications-btn,
    .user-ai-assistant-btn,
    .user-ai-assistant-chat,
    .sidebar-overlay {
        display: none !important;
    }
    
    .app-shell {
        margin-right: 0 !important;
    }
    
    .main-content {
        padding: 0 !important;
    }
    
    .table-wrapper {
        overflow-x: visible !important;
    }
    
    .data-table {
        width: 100% !important;
        min-width: auto !important;
    }
}

/* ===== Settings Section Styling ===== */
.settings-group {
    margin-bottom: 3rem;
}

.settings-group-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.settings-group-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
}

.settings-group-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    transition: color 0.3s ease;
}

.settings-group-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Responsive settings groups */
@media (max-width: 768px) {
    .settings-group {
        margin-bottom: 2rem;
    }
    
    .settings-group-title {
        font-size: 1.25rem;
    }
    
    .settings-group-subtitle {
        font-size: 0.875rem;
    }
    
    .settings-group-header {
        margin-bottom: 1.25rem;
        padding-bottom: 0.875rem;
    }
}

/* ===== Additional Utility Classes for Responsive Design ===== */
@media (max-width: 768px) {
    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }
    
    /* Full width on mobile */
    .full-width-mobile {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

@media (min-width: 769px) {
    /* Hide on desktop */
    .hide-desktop {
        display: none !important;
    }
    
    /* Show only on desktop */
    .show-desktop {
        display: block !important;
    }
}

/* ===== Safe Area Insets for Notched Devices ===== */
@supports (padding: max(0px)) {
    .main-content {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .mobile-topbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: max(calc(0.9rem + env(safe-area-inset-top) / 2), env(safe-area-inset-top));
    }
    
    .sidebar {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        padding-top: max(0px, env(safe-area-inset-top));
    }
    
    .navigation {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ===== Cross-Browser Compatibility Fixes ===== */
/* Fix for Safari iOS viewport height */
@supports (-webkit-touch-callout: none) {
    .sidebar,
    .main-content,
    .app-shell,
    .main-app {
        min-height: -webkit-fill-available;
    }
    
    @media (max-width: 1024px) {
        body.sidebar-open {
            height: -webkit-fill-available;
        }
    }
}

/* Fix for Firefox mobile */
@-moz-document url-prefix() {
    @media (max-width: 1024px) {
        .sidebar {
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
        }
    }
}

/* Fix for Edge/IE */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .sidebar {
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Mobile scrollbar - thinner and more subtle */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: var(--gray-400);
        border-radius: 2px;
    }
    
    /* Better scrollbar for sidebar on mobile */
    .sidebar::-webkit-scrollbar {
        width: 6px;
    }
    
    .sidebar::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }
    
    .sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }
    
    /* تحسين التمرير على الموبايل */
    .main-content {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
    
    .app-shell {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
}

/* ===== Dark Mode Toggle Button ===== */
.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10001;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.theme-toggle i {
    transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-toggle {
    background: var(--card-bg);
    border-color: var(--border-color);
}

/* Theme toggle in sidebar */
.sidebar .theme-toggle {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    height: auto;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.sidebar .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: none;
}

.sidebar .theme-toggle span {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== Notifications Badge ===== */
.notifications-btn {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    height: auto;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.notifications-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: none;
}

.notifications-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Header Actions Styles */
.header-theme-toggle,
.header-notifications-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.125rem;
}

.header-theme-toggle:hover,
.header-notifications-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.header-notifications-btn {
    position: relative;
}

.header-notifications-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    border: 2px solid var(--card-bg);
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: pulse 2s infinite;
}

.notifications-badge.show {
    display: flex;
}

/* ===== Animation for notifications ===== */
@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100px);
    }
}

/* ===== Activity Colors ===== */
.text-red-500 { color: var(--danger-color); }
.text-blue-500 { color: var(--primary-color); }
.text-green-500 { color: var(--success-color); }
.text-yellow-500 { color: var(--warning-color); }
.bg-gray-100 { background-color: var(--gray-100); }

/* ===== Data Tables ===== */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    min-width: 100%;
}

.data-table thead {
    background: var(--bg-secondary);
    transition: background-color 0.3s ease;
}

.data-table th {
    padding: 1rem;
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: color 0.3s ease, border-color 0.3s ease;
}

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

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

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

.badge-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* ===== Button Icons ===== */
.btn-icon {
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.btn-icon-primary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.btn-icon-primary:hover {
    background: rgba(37, 99, 235, 0.2);
}

.btn-icon-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.btn-icon-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.btn-icon-success:hover {
    background: rgba(16, 185, 129, 0.2);
}

.btn-icon-secondary {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.btn-icon-secondary:hover {
    background: rgba(107, 114, 128, 0.2);
    color: #4b5563;
}

/* ===== Grid Layout ===== */
.grid {
    display: grid;
}

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

.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.w-full { width: 100%; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.text-4xl { font-size: 2.25rem; }
.text-gray-300 { color: var(--gray-300); }
.text-gray-500 { color: var(--gray-500); }
.space-y-6 > * + * { margin-top: 1.5rem; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.modal-close {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    font-size: 1.25rem;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    background: var(--bg-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .modal-footer {
    background: var(--bg-secondary);
    border-top-color: var(--border-color);
}

/* ===== Textarea ===== */
textarea.form-input {
    resize: vertical;
    min-height: 100px;
    font-family: 'Cairo', sans-serif;
}

/* ===== Badge Info ===== */
.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

.btn-icon-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

.btn-icon-info:hover {
    background: rgba(6, 182, 212, 0.2);
}

/* ===== Additional Dark Mode Styles ===== */
[data-theme="dark"] .login-card h1 {
    color: var(--text-primary);
}

[data-theme="dark"] .login-card p {
    color: var(--text-secondary);
}

[data-theme="dark"] .empty-state p {
    color: var(--text-secondary);
}

[data-theme="dark"] .empty-state i {
    color: var(--text-tertiary);
}

[data-theme="dark"] .modal-close {
    color: var(--text-secondary);
}

[data-theme="dark"] .modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-footer {
    background: var(--bg-secondary);
    border-top-color: var(--border-color);
}

[data-theme="dark"] .card-body {
    color: var(--text-primary);
}

.header-company-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .header-company-name {
        font-size: 0.875rem;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

[data-theme="dark"] .company-logo-header {
    background: var(--card-bg);
    border-bottom-color: var(--border-color);
}

.ptw-form-section {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    background: var(--card-bg);
    padding: 1.5rem;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.05);
}

.ptw-form-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ptw-checklist-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .ptw-checklist-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.ptw-checklist-group {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--bg-secondary);
    padding: 1rem;
}

.ptw-checklist-group h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.ptw-check-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
}

.ptw-check-option:last-child {
    margin-bottom: 0;
}

.ptw-check-input {
    width: 1.1rem;
    height: 1.1rem;
}

.ptw-other-input {
    margin-top: 0.5rem;
}

.ptw-other-input.hidden {
    display: none;
}

.ptw-team-members {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ptw-team-member-row {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--bg-secondary);
    padding: 0.75rem;
}

.ptw-closure-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ptw-closure-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Enhanced Table Wrapper for Horizontal Scroll ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    position: relative;
    margin: 1rem 0;
    scroll-behavior: smooth;
}

/* Add scroll shadow indicators */
.table-wrapper {
    background: var(--bg-secondary);
    border-radius: 8px;
}

/* Ensure tables don't break layout */
.table-wrapper table {
    margin: 0;
}

/* Scroll indicator for tables on mobile */
@media (max-width: 768px) {
    .table-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table-wrapper.has-scroll::before,
    .table-wrapper.has-scroll::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px;
        pointer-events: none;
        z-index: 1;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .table-wrapper.has-scroll.scroll-right::before {
        opacity: 1;
        right: 0;
        background: linear-gradient(to right, var(--bg-secondary), transparent);
    }
    
    .table-wrapper.has-scroll.scroll-left::after {
        opacity: 1;
        left: 0;
        background: linear-gradient(to left, var(--bg-secondary), transparent);
    }
}

/* ===== Form Grid Responsive Improvements ===== */
@media (max-width: 768px) {
    /* All grid columns stack on mobile */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5,
    .grid-cols-6 {
        grid-template-columns: 1fr !important;
    }
    
    /* Form groups stack vertically */
    .form-group,
    .form-row {
        flex-direction: column;
    }
    
    /* Labels and inputs full width */
    .form-group label,
    .form-row label {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea,
    .form-row input,
    .form-row select,
    .form-row textarea {
        width: 100%;
    }
}

/* ===== Touch-Friendly Interactive Elements ===== */
@media (max-width: 1024px) {
    /* Ensure all clickable elements are touch-friendly */
    a,
    button,
    input[type="button"],
    input[type="submit"],
    input[type="checkbox"],
    input[type="radio"],
    select,
    .nav-item,
    .btn-primary,
    .btn-secondary,
    .btn-icon-primary,
    .btn-icon-danger,
    .btn-icon-success,
    .btn-icon-info {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
    }
    
    /* Remove double-tap zoom on buttons */
    button,
    a.btn-primary,
    a.btn-secondary {
        touch-action: manipulation;
    }
    
    /* Improve checkbox and radio button sizes */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
    }
    
    /* Better spacing for form elements */
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    label {
        margin-bottom: 0.5rem;
        display: block;
        font-weight: 600;
    }
}

/* ===== Update Management Styles ===== */
.form-select {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 12px;
}

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

.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    resize: vertical;
    min-height: 100px;
}

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

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: #0891b2;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.btn-success {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #15803d 0%, #16a34a 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.settings-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

@media (max-width: 768px) {
    .settings-container {
        padding: 1rem;
    }
}

/* ===== User AI Assistant Chat Interface ===== */
.user-ai-assistant-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    transition: var(--transition);
    animation: pulse 2s infinite;
}

.user-ai-assistant-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.user-ai-assistant-btn:active {
    transform: scale(0.95);
}

.user-ai-assistant-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
    }
}

.user-ai-assistant-chat {
    position: fixed;
    bottom: 100px;
    left: 30px;
    width: 400px;
    max-width: calc(100vw - 60px);
    height: 600px;
    max-height: calc(100vh - 150px);
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.user-ai-assistant-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-ai-assistant-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-ai-assistant-header-content i {
    font-size: 24px;
}

.user-ai-assistant-header-content h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.user-ai-assistant-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-ai-assistant-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.user-ai-assistant-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.user-ai-assistant-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.user-ai-assistant-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.user-ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary);
}

.user-ai-assistant-messages::-webkit-scrollbar {
    width: 6px;
}

.user-ai-assistant-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.user-ai-assistant-messages::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.user-ai-assistant-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

.user-ai-message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-ai-message-user {
    flex-direction: row-reverse;
}

.user-ai-message-assistant {
    flex-direction: row;
}

.user-ai-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.user-ai-message-user .user-ai-message-avatar {
    background: var(--primary-color);
    color: white;
}

.user-ai-message-assistant .user-ai-message-avatar {
    background: var(--gray-200);
    color: var(--gray-700);
}

.user-ai-message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-ai-message-user .user-ai-message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.user-ai-message-assistant .user-ai-message-content {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.user-ai-message-content p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.user-ai-message-text {
    width: 100%;
}

.user-ai-message-text p {
    margin: 4px 0;
}

.user-ai-message-text p:first-child {
    margin-top: 0;
}

.user-ai-message-text p:last-child {
    margin-bottom: 0;
}

.user-ai-message-list-item {
    padding-right: 16px;
    position: relative;
}

.user-ai-message-heading {
    font-weight: 600;
    margin: 8px 0 4px 0 !important;
}

.user-ai-message-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 11px;
}

.user-ai-message-content .user-ai-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.user-ai-quick-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-ai-quick-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.user-ai-quick-button i {
    font-size: 12px;
}

.user-ai-assistant-input-container {
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
    padding: 12px;
}

.user-ai-assistant-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.user-ai-quick-action-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.user-ai-quick-action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.user-ai-quick-action-btn i {
    font-size: 12px;
}

.user-ai-assistant-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-ai-assistant-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.user-ai-assistant-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.user-ai-assistant-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.user-ai-assistant-send:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.user-ai-assistant-send:active {
    transform: scale(0.95);
}

.user-ai-assistant-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.user-ai-loading {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.user-ai-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: bounce 1.4s infinite ease-in-out both;
}

.user-ai-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.user-ai-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Responsive Design for AI Assistant */
@media (max-width: 768px) {
    .user-ai-assistant-chat {
        width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
        bottom: 80px;
        height: calc(100vh - 120px);
        max-width: none;
        max-height: none;
    }
    
    .user-ai-assistant-btn {
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .user-ai-assistant-quick-actions {
        display: none;
    }
    
    .user-ai-assistant-header {
        padding: 12px;
    }
    
    .user-ai-assistant-header-content h3 {
        font-size: 16px;
    }
    
    .user-ai-assistant-input-container {
        padding: 10px;
    }
    
    .user-ai-assistant-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .user-ai-assistant-send {
        width: 40px;
        height: 40px;
    }
}

/* Additional Mobile Optimizations */
@media (max-width: 480px) {
    .user-ai-assistant-chat {
        width: 100vw;
        left: 0;
        right: 0;
        bottom: 70px;
        height: calc(100vh - 70px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .user-ai-assistant-btn {
        bottom: 15px;
        left: 15px;
        width: 48px;
        height: 48px;
    }
}

/* ===== Safety & Health Management Module Styles ===== */
.shm-tab-btn {
    transition: all 0.3s ease;
    position: relative;
}

.shm-tab-btn:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.shm-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px 2px 0 0;
}

/* Team Member Cards */
#team-members-list .bg-white {
    transition: all 0.3s ease;
}

#team-members-list .bg-white:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* KPI Cards - Legacy style for safetyhealthmanagement module only */
/* This style applies only to .kpi-card with single class modifiers (success, warning, etc.) */
/* and does not affect .kpi-card with kpi- prefix classes (kpi-danger, kpi-success, etc.) */
/* Using more specific selector to avoid conflicts */
.kpi-card:not(.kpi-primary):not(.kpi-success):not(.kpi-warning):not(.kpi-info):not(.kpi-danger):not(.kpi-purple) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.kpi-card:not(.kpi-primary):not(.kpi-success):not(.kpi-warning):not(.kpi-info):not(.kpi-danger):not(.kpi-purple):hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.kpi-card.success:not(.kpi-success) {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.kpi-card.warning:not(.kpi-warning) {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.kpi-card.danger:not(.kpi-danger) {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.kpi-card.info:not(.kpi-info) {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

/* Performance Chart Container */
.performance-chart-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

/* Attendance Calendar */
.attendance-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.attendance-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.attendance-day.present {
    background-color: #10b981;
    color: white;
}

.attendance-day.absent {
    background-color: #ef4444;
    color: white;
}

.attendance-day.late {
    background-color: #f59e0b;
    color: white;
}

.attendance-day.field-work {
    background-color: #06b6d4;
    color: white;
}

.attendance-day:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* Organizational Structure Tree */
.org-structure-tree {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.org-node {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    transition: all 0.3s ease;
}

.org-node:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.org-node::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 12px;
    background-color: var(--border-color);
}

.org-node:first-child::before {
    display: none;
}

/* Responsive adjustments for Safety Health Management */
@media (max-width: 768px) {
    .shm-tab-btn {
        padding: 10px 12px !important;
        font-size: 0.875rem;
    }
    
    #team-members-list {
        grid-template-columns: 1fr !important;
    }
    
    .attendance-calendar {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0.25rem;
    }
    
    .attendance-day {
        font-size: 0.75rem;
    }
}

/* Dropdown Menu Styles - Enhanced for Mobile */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1000;
    display: none;
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile dropdown adjustments */
@media (max-width: 768px) {
    .dropdown-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
        animation: slideUpFromBottom 0.3s ease;
    }
    
    @keyframes slideUpFromBottom {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

[data-theme="dark"] .dropdown-menu {
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
    cursor: pointer;
    font-size: 14px;
    min-height: 44px; /* Touch-friendly */
    touch-action: manipulation;
}

[data-theme="dark"] .dropdown-item {
    border-bottom-color: var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: var(--gray-100);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--gray-700);
}

.dropdown-item i {
    margin-left: 8px;
}

/* Modal improvements for action details */
.modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-header .modal-close:hover {
    background-color: var(--gray-100);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-header .modal-close:hover {
    background-color: var(--gray-700);
}

/* ===== Additional Mobile Enhancements ===== */

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
    }
}

/* Better select dropdowns on mobile */
@media (max-width: 768px) {
    select.form-select {
        background-position: left 1rem center;
        padding-right: 1rem;
        padding-left: 3rem;
    }
}

/* Improved table responsiveness */
@media (max-width: 768px) {
    .data-table {
        display: block;
        width: 100%;
        border-collapse: collapse;
    }
    
    .data-table thead {
        display: none; /* Hide headers on mobile for card-style view */
    }
    
    .data-table tbody {
        display: block;
        width: 100%;
    }
    
    .data-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 1rem;
        background: var(--card-bg);
    }
    
    .data-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
        text-align: right;
    }
    
    .data-table td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-left: 1rem;
        color: var(--text-secondary);
    }
}

/* Landscape orientation optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    .mobile-topbar {
        min-height: 50px;
        padding: 0.5rem 1rem;
    }
    
    .sidebar {
        max-width: 60vw;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* High DPI displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .kpi-icon,
    .user-avatar {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark mode improvements for mobile */
@media (max-width: 768px) {
    [data-theme="dark"] .mobile-topbar {
        background: var(--card-bg);
        border-bottom-color: var(--border-color);
    }
    
    [data-theme="dark"] .sidebar {
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.8);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary,
    .btn-secondary {
        border: 2px solid currentColor;
    }
    
    .nav-item {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}

/* Hover capability detection */
@media (hover: none) {
    .btn-primary:hover,
    .btn-secondary:hover,
    .nav-item:hover {
        transform: none; /* Disable hover transforms on touch devices */
    }
}

/* Pointer coarse (touch devices) */
@media (pointer: coarse) {
    /* Increase tap targets */
    .nav-item,
    .btn-icon,
    .dropdown-item {
        min-height: 48px;
        min-width: 48px;
    }
}

/* ========================================
   مصفوفة تقييم المخاطر 5×5 - تصميم مدمج وتفاعلي
   Risk Assessment Matrix 5x5 - Compact & Interactive
   ======================================== */

.risk-matrix-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow-md);
    margin: 0.75rem 0;
    border: 1px solid var(--border-color);
    max-width: 500px;
}

.risk-matrix-container.full-width {
    max-width: 100%;
}

.risk-matrix-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.risk-matrix-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.risk-matrix-title i {
    color: var(--primary-color);
    font-size: 1rem;
}

.risk-matrix-subtitle {
    color: var(--text-tertiary);
    font-size: 0.7rem;
    margin-top: 0.15rem;
}

/* Legend Compact */
.risk-matrix-legend {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.65rem;
}

.risk-legend-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.2rem 0.4rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.risk-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Matrix Layout */
.risk-matrix-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.risk-matrix-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.risk-matrix-y-label {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--primary-color);
    letter-spacing: 1px;
}

.risk-matrix-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Grid - Compact Design */
.risk-matrix-grid {
    display: grid;
    grid-template-columns: 40px repeat(5, 1fr);
    gap: 2px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--border-color);
    padding: 2px;
}

/* Cells - Compact & Interactive */
.risk-matrix-cell {
    aspect-ratio: 1;
    min-height: 36px;
    max-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    font-weight: 700;
    font-size: 0.85rem;
    user-select: none;
}

.risk-matrix-cell:not(.risk-matrix-header-cell):hover {
    transform: scale(1.12);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.risk-matrix-cell:not(.risk-matrix-header-cell):active {
    transform: scale(0.95);
}

.risk-matrix-cell.selected {
    outline: 2px solid #fff;
    outline-offset: -2px;
    box-shadow: 0 0 0 3px var(--primary-color), 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 15;
}

.risk-matrix-cell-value {
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.risk-matrix-cell-label {
    display: none;
}

/* Risk Level Colors - Gradient Based */
.risk-level-1, .risk-level-2 { background: #22c55e; color: #fff; }
.risk-level-3, .risk-level-4 { background: #84cc16; color: #1a1a1a; }
.risk-level-5, .risk-level-6 { background: #eab308; color: #1a1a1a; }
.risk-level-8, .risk-level-9 { background: #f97316; color: #fff; }
.risk-level-10, .risk-level-12 { background: #ef4444; color: #fff; }
.risk-level-15, .risk-level-16 { background: #dc2626; color: #fff; }
.risk-level-20, .risk-level-25 { background: #991b1b; color: #fff; }

/* Header Cells - Compact */
.risk-matrix-header-cell {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.7rem;
    cursor: default;
    text-align: center;
    padding: 0.25rem;
    min-height: 36px !important;
}

.risk-matrix-header-cell:hover {
    transform: none !important;
    box-shadow: none !important;
}

.risk-matrix-header-cell .header-num {
    font-size: 0.85rem;
    font-weight: 800;
    display: block;
    line-height: 1;
}

.risk-matrix-header-cell .header-txt {
    font-size: 0.55rem;
    opacity: 0.9;
    display: block;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.risk-matrix-corner {
    background: var(--bg-tertiary) !important;
    cursor: default;
}

.risk-matrix-corner i {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

/* X-Axis Label */
.risk-matrix-x-axis {
    text-align: center;
    margin-top: 0.35rem;
}

.risk-matrix-x-label {
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--primary-color);
    letter-spacing: 1px;
}

/* Selection Info - Compact */
.risk-matrix-selection-info {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: none;
}

.risk-matrix-selection-info.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.risk-selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.risk-selection-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.risk-selection-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1rem;
    min-width: 45px;
}

.risk-selection-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.risk-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.risk-detail-label {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.risk-detail-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Action Text */
.risk-action-text {
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .risk-matrix-container {
        padding: 0.75rem;
        max-width: 100%;
    }

    .risk-matrix-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .risk-matrix-legend {
        width: 100%;
        justify-content: flex-start;
    }

    .risk-matrix-grid {
        grid-template-columns: 32px repeat(5, 1fr);
    }

    .risk-matrix-cell {
        min-height: 32px;
        max-height: 38px;
    }

    .risk-matrix-cell-value {
        font-size: 0.8rem;
    }

    .risk-matrix-header-cell .header-txt {
        display: none;
    }

    .risk-selection-details {
        grid-template-columns: 1fr 1fr;
    }
}

/* Dark Mode */
[data-theme="dark"] .risk-matrix-container {
    background: var(--card-bg);
}

[data-theme="dark"] .risk-matrix-header-cell {
    background: #334155;
}

[data-theme="dark"] .risk-legend-item {
    background: var(--bg-tertiary);
}

/* ===== Clinic Tabs ===== */
.clinic-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.clinic-tab-btn {
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #374151;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-family: 'Cairo', sans-serif;
    white-space: nowrap;
    position: relative;
}

.clinic-tab-btn i {
    margin-left: 0.5rem;
    font-size: 1rem;
    color: #374151;
    transition: color 0.2s ease;
}

.clinic-tab-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.clinic-tab-btn.active {
    background: #1e40af;
    border-color: #1e40af;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(30, 64, 175, 0.25);
    font-weight: 600;
}

.clinic-tab-btn.active i {
    color: #ffffff;
}

.clinic-tab-btn.active:hover {
    background: #1e3a8a;
    border-color: #1e3a8a;
    box-shadow: 0 3px 8px rgba(30, 64, 175, 0.3);
}

/* Badge داخل التبويب */
.clinic-tab-btn .badge {
    margin-right: 0.5rem;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
}

/* Dark mode support */
[data-theme="dark"] .clinic-tab-btn {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

[data-theme="dark"] .clinic-tab-btn i {
    color: #d1d5db;
}

[data-theme="dark"] .clinic-tab-btn:hover {
    background: #374151;
    border-color: #4b5563;
}

[data-theme="dark"] .clinic-tab-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

[data-theme="dark"] .clinic-tab-btn.active i {
    color: #ffffff;
}

/* ========================================
   تحسينات التوافق مع مستويات التكبير (Zoom)
   ======================================== */

/* منع انزلاق العناصر عند التكبير */
* {
    box-sizing: border-box;
}

/* ضمان عدم ظهور Scroll أفقي عند التكبير */
html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}

/* حماية العناصر من الخروج عن الحدود */
.app-shell,
.main-content,
.sidebar,
.content-card,
.modal-content {
    max-width: 100%;
    overflow-x: hidden;
}

/* حماية الجداول من التكسر عند التكبير */
.table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    min-width: 100%;
    table-layout: auto;
}

/* حماية النماذج من التكسر */
.form-group,
.form-row {
    max-width: 100%;
    overflow-x: hidden;
}

.form-group input,
.form-group select,
.form-group textarea,
.form-row input,
.form-row select,
.form-row textarea {
    max-width: 100%;
    box-sizing: border-box;
}

/* حماية Grid من التكسر */
.content-grid,
.kpi-grid,
.stats-grid {
    max-width: 100%;
    overflow-x: hidden;
}

/* حماية الأزرار من التكسر */
.btn-primary,
.btn-secondary,
.btn-icon-primary,
.btn-icon-danger {
    white-space: nowrap;
    min-width: fit-content;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* حماية Modals من الخروج عن الشاشة */
.modal-content {
    max-width: min(95vw, 600px);
    max-height: min(90vh, 800px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* حماية Sidebar من التكسر */
.sidebar {
    max-width: 100%;
    overflow-x: hidden;
}

/* حماية Navigation من التكسر */
.navigation {
    max-width: 100%;
    overflow-x: hidden;
}

.nav-item {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* تحسينات خاصة لمستويات التكبير المختلفة */

/* عند التكبير 80% */
@media screen {
    /* ضمان أن العناصر تبقى قابلة للقراءة */
    body {
        font-size: clamp(12px, 1rem, 16px);
    }
}

/* عند التكبير 125% */
@media screen {
    /* ضمان أن العناصر لا تتداخل */
    .content-card {
        padding: clamp(1rem, 2vw, 2rem);
    }
    
    .section-title {
        font-size: clamp(1.25rem, 3vw, 2rem);
    }
}

/* حماية الصور من التكسر */
img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* حماية الأيقونات */
i[class*="fa-"] {
    display: inline-block;
    flex-shrink: 0;
}

/* منع انزلاق العناصر المطلقة */
.absolute,
.fixed {
    max-width: 100vw;
    left: auto;
    right: auto;
}

/* حماية Cards من التكسر */
.card,
.content-card {
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* حماية النصوص الطويلة */
p, span, div, label {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* حماية Tables من التكسر عند التكبير */
@media screen {
    .data-table th,
    .data-table td {
        white-space: nowrap;
        min-width: fit-content;
    }
    
    /* على Mobile، السماح بالتمرير الأفقي */
    @media (max-width: 768px) {
        .data-table th,
        .data-table td {
            white-space: normal;
            word-wrap: break-word;
        }
    }
}

/* تحسينات للتوافق مع جميع المتصفحات عند التكبير */

/* Chrome/Edge */
@supports (-webkit-appearance: none) {
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Firefox */
@-moz-document url-prefix() {
    * {
        -moz-font-smoothing: grayscale;
    }
}

/* Safari */
@supports (-webkit-touch-callout: none) {
    * {
        -webkit-font-smoothing: antialiased;
    }
}

/* منع مشاكل التكبير في Mobile */
@media (max-width: 1024px) {
    * {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* منع التكبير التلقائي في حقول الإدخال على iOS */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* حماية Layout من التكسر عند أي مستوى تكبير */
.main-app,
.app-shell {
    min-width: 0;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ضمان أن جميع العناصر القابلة للتمرير تعمل بشكل صحيح */
.scrollable,
.overflow-auto,
.overflow-y-auto {
    overflow-x: hidden !important;
}

/* حماية Flexbox containers */
.flex,
.d-flex {
    min-width: 0;
    max-width: 100%;
}

.flex > * {
    min-width: 0;
    flex-shrink: 1;
}

/* حماية Grid containers */
.grid {
    min-width: 0;
    max-width: 100%;
}

/* منع overflow في جميع الاتجاهات غير المرغوبة */
.container,
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
    padding-left: clamp(1rem, 2vw, 2rem);
    padding-right: clamp(1rem, 2vw, 2rem);
}

/* حماية Login Screen */
.login-screen {
    max-width: 100vw;
    overflow-x: hidden;
}

.login-card {
    max-width: min(95vw, 420px);
    overflow-x: hidden;
}

/* تحسينات نهائية للتوافق */
@media screen {
    /* ضمان أن جميع العناصر تبقى داخل Viewport */
    * {
        box-sizing: border-box;
    }
    
    /* منع أي عنصر من الخروج عن الحدود */
    body > * {
        max-width: 100vw;
    }
}

/* ========================================
   تحسينات خاصة لكل متصفح
   ======================================== */

/* ===== Firefox Specific Fixes ===== */
@-moz-document url-prefix() {
    /* تحسين عرض الخطوط */
    * {
        -moz-font-smoothing: grayscale;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* إصلاح مشكلة overflow في Firefox */
    html, body {
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    }
    
    /* تحسين Sidebar scrollbar */
    .sidebar {
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    }
    
    /* إصلاح مشكلة backdrop-filter في Firefox */
    .modal-overlay {
        background: rgba(0, 0, 0, 0.5);
    }
    
    /* تحسين Grid في Firefox */
    .content-grid,
    .kpi-grid,
    .stats-grid {
        display: grid;
        grid-template-columns: inherit;
    }
    
    /* إصلاح مشكلة RTL في Firefox */
    [dir="rtl"] {
        direction: rtl;
        text-align: right;
    }
    
    /* تحسين Forms في Firefox */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        -moz-appearance: none;
        appearance: none;
    }
    
    /* إصلاح مشكلة focus في Firefox */
    *:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* ===== Edge Specific Fixes ===== */
@supports (-ms-ime-align: auto) {
    /* Edge القديم (EdgeHTML) */
    html, body {
        -ms-overflow-style: -ms-autohiding-scrollbar;
        overflow-x: hidden;
    }
    
    .sidebar {
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
    
    /* إصلاح Grid في Edge القديم */
    .content-grid,
    .kpi-grid {
        display: -ms-grid;
        -ms-grid-columns: inherit;
    }
}

/* Edge الجديد (Chromium-based) */
@supports (selector(:has(*))) {
    /* Edge Chromium يدعم :has() */
    .content-card:has(.table-wrapper) {
        overflow-x: auto;
    }
}

/* ===== Safari Specific Fixes ===== */
@supports (-webkit-touch-callout: none) {
    /* Safari على macOS و iOS */
    
    /* إصلاح Viewport Height */
    html, body,
    .sidebar,
    .main-content,
    .app-shell,
    .main-app {
        min-height: -webkit-fill-available;
    }
    
    /* إصلاح Safe Area Insets */
    @supports (padding: max(0px)) {
        .main-content {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
            padding-top: max(1rem, env(safe-area-inset-top));
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
        
        .mobile-topbar {
            padding-top: max(0.9rem, env(safe-area-inset-top));
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
    }
    
    /* إصلاح مشكلة Scroll في Safari */
    .sidebar,
    .main-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* إصلاح مشكلة backdrop-filter في Safari */
    .modal-overlay {
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }
    
    /* تحسين الخطوط في Safari */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* إصلاح مشكلة RTL في Safari */
    [dir="rtl"] {
        direction: rtl;
    }
    
    /* إصلاح مشكلة Forms في Safari */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* منع التكبير التلقائي في حقول الإدخال على iOS */
    @media (max-width: 1024px) {
        input,
        select,
        textarea {
            font-size: 16px !important;
        }
    }
    
    /* إصلاح مشكلة position: sticky في Safari */
    .mobile-topbar {
        position: -webkit-sticky;
        position: sticky;
    }
}

/* ===== Mobile WebView Specific Fixes ===== */
@media (max-width: 1024px) {
    /* تحسينات عامة لـ WebView */
    html, body {
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* تحسين Touch Events */
    * {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
    }
    
    /* إصلاح Safe Area في WebView */
    @supports (padding: max(0px)) {
        .main-content,
        .mobile-topbar,
        .sidebar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
    }
}

/* ===== Brave Browser Specific Fixes ===== */
/* Brave يستخدم Blink engine مثل Chrome، لكن قد يحتاج تحسينات خاصة */
@supports (selector(:has(*))) {
    /* Brave يدعم الميزات الحديثة */
    .content-card:has(.table-wrapper) {
        overflow-x: auto;
    }
}

/* ===== Opera Specific Fixes ===== */
@supports (-o-appearance: none) {
    /* Opera القديم */
    html, body {
        overflow-x: hidden;
    }
}

/* Opera الجديد (Chromium-based) - نفس Chrome */

/* ===== Samsung Internet Specific Fixes ===== */
/* Samsung Internet يستخدم Chromium، لكن قد يحتاج تحسينات */
@media (max-width: 1024px) {
    /* تحسينات خاصة لـ Samsung Internet */
    * {
        -webkit-text-size-adjust: 100%;
    }
}

/* ===== Yandex Browser Specific Fixes ===== */
/* Yandex Browser يستخدم Chromium */

/* ===== UC Browser Specific Fixes ===== */
@media (max-width: 1024px) {
    /* UC Browser قد يحتاج تحسينات خاصة */
    * {
        -webkit-text-size-adjust: 100%;
    }
}

/* ===== Internet Explorer (Legacy Support) ===== */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    /* IE 10+ */
    html, body {
        -ms-overflow-style: -ms-autohiding-scrollbar;
        overflow-x: hidden;
    }
    
    .sidebar {
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
    
    /* Fallback للـ Grid في IE */
    .content-grid,
    .kpi-grid {
        display: -ms-grid;
        display: grid;
    }
    
    /* Fallback للـ Flexbox في IE */
    .flex,
    .d-flex {
        display: -ms-flexbox;
        display: flex;
    }
}

/* ===== متصفحات غير معروفة - تحسينات عامة ===== */
/* ضمان التوافق الأساسي مع أي متصفح */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Fallback للـ CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #aa3636;
}

/* Fallback للـ Grid */
@supports not (display: grid) {
    .content-grid,
    .kpi-grid,
    .stats-grid {
        display: flex;
        flex-wrap: wrap;
    }
    
    .content-grid > *,
    .kpi-grid > *,
    .stats-grid > * {
        flex: 1 1 auto;
        min-width: 200px;
    }
}

/* Fallback للـ Flexbox */
@supports not (display: flex) {
    .flex,
    .d-flex {
        display: block;
    }
}

/* Fallback للـ backdrop-filter */
@supports not (backdrop-filter: blur(4px)) {
    .modal-overlay {
        background: rgba(0, 0, 0, 0.6);
    }
}

/* Fallback للـ CSS Variables */
@supports not (--css: variables) {
    .btn-primary {
        background: #2563eb;
        color: white;
    }
    
    .btn-secondary {
        background: #6b7280;
        color: white;
    }
    
    .card,
    .content-card {
        background: white;
        border: 1px solid #e5e7eb;
    }
}

/* ===== تحسينات عامة لجميع المتصفحات ===== */
/* ضمان عدم وجود Scroll أفقي */
html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    position: relative;
}

/* تحسين الأداء */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

