/* ========================================
   نظام جرد قطع الغيار - Jard Tesla Alkhlij
   Blazor Theme - Modern & Clean RTL
   
   File Structure:
   - variables.css : CSS Custom Properties (colors, spacing, shadows)
   - app.css       : Base styles, components, layouts (this file)
   - utilities.css : Utility classes (spacing, flex, text, etc.)
   ======================================== */

/* NOTE: CSS Variables are defined in variables.css */

/* ===== Global Styles ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Mobile Native Feel: Disable 300ms tap delay */
    touch-action: manipulation;
}

/* Remove resize handles and focus outlines globally */
*:focus {
    outline: none;
}

textarea, div, section {
    resize: none;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    /* Mobile Native Feel: Remove tap highlight */
    -webkit-tap-highlight-color: transparent;
    /* Mobile Native Feel: Prevent text size adjustment */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Mobile Native Feel: Dynamic viewport height */
    height: 100%;
    height: 100dvh;
}

@supports not (height: 100dvh) {
    html {
        height: -webkit-fill-available;
    }
}

/* Mobile Native Feel: Safe area CSS variables */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

body {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--gray-100);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    direction: rtl;
    /* Mobile Native Feel: Prevent overscroll bounce */
    overscroll-behavior-y: contain;
}

/* ===== Mobile Native Feel: CRITICAL - Prevent iOS Auto-Zoom ===== */
/* iOS auto-zooms when font-size < 16px on focus. This MUST be global. */
@media (max-width: 768px) {
    /* Force ALL form elements to 16px */
    input,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="tel"],
    select,
    textarea,
    .form-control,
    .form-select {
        font-size: 16px !important;
    }
    
    /* Maintain 16px on focus/active states */
    input:focus,
    input:active,
    select:focus,
    textarea:focus,
    .form-control:focus,
    .form-select:focus {
        font-size: 16px !important;
    }
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Admin Layout ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
    transition: all 0.3s ease;
    --sidebar-current-width: var(--sidebar-width);
}

/* Collapsed state class on layout */
.admin-layout.sidebar-collapsed .admin-main {
    margin-right: var(--sidebar-width-collapsed, 70px);
}

.admin-sidebar {
    width: var(--sidebar-current-width, var(--sidebar-width));
    background: linear-gradient(180deg, #151922 0%, #0c0f14 100%);
    color: var(--white);
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.25);
}

/* Sidebar Resize Handle */
.sidebar-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    cursor: ew-resize;
    z-index: 1001;
    transition: background 0.2s ease;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle:active {
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

/* Sidebar Toggle Button (inside sidebar) */
.sidebar-toggle-btn {
    position: absolute;
    left: -12px;
    top: 80px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border: 2px solid #1e40af;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1002;
    font-size: 0.65rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.sidebar-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
}

/* Collapsed Sidebar State */
.admin-sidebar.collapsed {
    width: var(--sidebar-width-collapsed, 70px) !important;
}

.admin-sidebar.collapsed .sidebar-brand {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
    transition: all 0.2s ease;
}

.admin-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1.25rem 0.5rem;
}

.admin-sidebar.collapsed .sidebar-header > i {
    font-size: 1.5rem;
}

.admin-sidebar.collapsed .sidebar-resize-handle {
    display: none;
}

.admin-sidebar.collapsed .menu-group-header span,
.admin-sidebar.collapsed .menu-group-header .group-toggle,
.admin-sidebar.collapsed .sidebar-menu .nav-link span,
.admin-sidebar.collapsed .menu-section-title,
.admin-sidebar.collapsed .coming-soon-badge,
.admin-sidebar.collapsed .menu-logout span {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.admin-sidebar.collapsed .sidebar-menu .nav-link,
.admin-sidebar.collapsed .menu-group-header,
.admin-sidebar.collapsed .menu-logout a {
    justify-content: center;
    padding: 0.75rem 0;
}

.admin-sidebar.collapsed .sidebar-menu .nav-link i,
.admin-sidebar.collapsed .menu-group-header i:first-child,
.admin-sidebar.collapsed .menu-logout a i {
    margin: 0;
    font-size: 1.25rem;
}

.admin-sidebar.collapsed .menu-group-items {
    display: none !important;
}

.admin-sidebar.collapsed .menu-group {
    border: none;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Popup Menu for Collapsed Sidebar */
.menu-popup {
    display: none;
    position: absolute;
    right: calc(100% + 8px);
    left: auto;
    top: 0;
    min-width: 220px;
    background: linear-gradient(135deg, #1a2332 0%, #151922 100%);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.4), 0 0 40px rgba(96, 165, 250, 0.1);
    z-index: 1100;
    animation: popupSlideIn 0.2s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Show popup when group is active AND sidebar is collapsed */
.admin-sidebar.collapsed .menu-group.popup-active .menu-popup {
    display: block;
}

.popup-header {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.75rem 1rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
}

.popup-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.popup-link:hover {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.popup-link.active {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

.popup-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: inherit;
}

.popup-link.disabled-link {
    opacity: 0.5;
    pointer-events: none;
}

/* Collapsed state - show pointer cursor on groups */
.admin-sidebar.collapsed .menu-group-header {
    cursor: pointer;
}

.admin-sidebar.collapsed .menu-group-header:hover {
    background: rgba(96, 165, 250, 0.1);
    border-radius: 8px;
}

/* Sidebar Collapse Toggle Button (in header/topbar) */
.sidebar-collapse-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-inline-end: 0.75rem;
}

.sidebar-collapse-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

/* Header Start Section */
.header-start {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Show collapse button only on desktop */
@media (min-width: 769px) {
    .sidebar-collapse-btn {
        display: flex;
    }
}

/* Hide mobile menu toggle on desktop */
@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-header > i {
    font-size: 2rem;
    color: #60a5fa;
    flex-shrink: 0;
}

.sidebar-brand {
    flex: 1;
    min-width: 0;
    transition: all 0.2s ease;
}

.sidebar-header h2 {
    font-size: 1.15rem;
    margin: 0;
    color: var(--white);
    white-space: nowrap;
    font-weight: 700;
}

.sidebar-header p {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin: 0.15rem 0 0 0;
    white-space: nowrap;
}

.sidebar-close {
    display: none;
    margin-right: auto;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

/* Sidebar Menu Wrapper */
.sidebar-menu-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
}

.sidebar-menu-wrapper::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.sidebar-menu-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Menu Groups */
.menu-group {
    margin: 0.25rem 0.75rem;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 0.2s ease;
}

.menu-group:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
}

.menu-group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 600;
    user-select: none;
    border-radius: 10px;
}

.menu-group-header:hover {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.05);
}

.menu-group-header i:first-child {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
    border-radius: 6px;
    flex-shrink: 0;
}

.menu-group-header span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-group-header .group-toggle {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    opacity: 0.5;
    color: rgba(255, 255, 255, 0.5);
}

.menu-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.15);
}

.menu-group-items.open {
    max-height: 500px;
}

.menu-group-items li {
    margin: 0;
}

.menu-group-items .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    padding-right: 2.75rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
    font-size: 0.85rem;
}

.menu-group-items .nav-link:hover,
.menu-group-items .nav-link.active {
    background: rgba(96, 165, 250, 0.08);
    color: var(--white);
    border-right-color: #3b82f6;
    text-decoration: none;
}

.menu-group-items .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.7;
}

.menu-group-items .nav-link.active i {
    opacity: 1;
    color: #60a5fa;
}

.menu-group-items .nav-link:hover i {
    opacity: 1;
}

/* Menu Logout */
.menu-logout {
    margin: 0.5rem 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.menu-logout a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 10px;
    font-size: 0.85rem;
}

.menu-logout a:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.menu-logout a i {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.menu-logout a:hover i {
    color: #f87171;
    background: rgba(239, 68, 68, 0.2);
}

/* Disabled Links & Coming Soon Badge */
.sidebar-menu .nav-link.disabled-link {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.coming-soon-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 8px;
    margin-right: auto;
    margin-left: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.admin-main {
    flex: 1;
    margin-right: var(--sidebar-current-width, var(--sidebar-width));
    background: var(--gray-100);
    min-height: 100vh;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-header {
    background: var(--white);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: auto 1fr auto auto; /* menu-toggle | title | notification | user-menu */
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header h1 {
    font-size: 1.25rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-start {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Notification Bell ===== */
.notification-bell {
    position: relative;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.notification-bell:hover {
    background: var(--hover-color);
    color: var(--primary-color);
}

.notification-badge {
    position: absolute;
    top: 2px;
    left: 2px; /* للـ RTL - يظهر على اليسار */
    background: var(--danger-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    z-index: 10; /* فوق الأيقونة */
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    width: 420px;
    max-width: 90vw;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-height: 600px;
    overflow-y: auto;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.btn-link-sm {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
}

.btn-link-sm:hover {
    text-decoration: underline;
}

.notification-section {
    padding: 0.75rem 0;
}

.section-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.notification-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    transition: background var(--transition);
    cursor: pointer;
    border-right: 3px solid transparent;
}

.notification-item:hover {
    background: var(--hover-color);
}

.notification-item.unread {
    background: rgba(var(--primary-rgb), 0.05);
    border-right-color: var(--primary-color);
}

.task-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.task-icon.task-import {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.task-icon.task-export {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success-color);
}

.task-icon.task-sync {
    background: rgba(var(--info-rgb), 0.1);
    color: var(--info-color);
}

.task-icon.task-process {
    background: rgba(var(--warning-rgb), 0.1);
    color: var(--warning-color);
}

.task-icon.success {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success-color);
}

.task-icon.error {
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger-color);
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-description {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.task-message {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.task-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar-mini {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 3px;
    transition: width 0.3s ease;
    max-width: 100%; /* تأكد من عدم تجاوز 100% */
    min-width: 2%; /* حد أدنى للرؤية */
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
}

.task-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.stat-success {
    color: var(--success-color);
}

.stat-error {
    color: var(--danger-color);
}

.task-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.notification-empty {
    text-align: center;
    padding: 3rem 1.25rem;
    color: var(--text-light);
}

.notification-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.notification-empty p {
    margin: 0;
}

.notification-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem;
}

.btn-link:hover {
    text-decoration: underline;
}

.admin-content {
    padding: 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--dark-color);
}

/* ===== Login Page ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 1rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

.login-logo h1 {
    color: var(--dark-color);
    font-size: 1.5rem;
}

.login-logo p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    /* Mobile Native Feel: Prevent iOS auto-zoom (min 16px) */
    font-size: max(16px, 1rem);
    font-family: inherit;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background-color: var(--white);
    color: var(--dark-color);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.form-control-sm {
    padding: 0.5rem 0.75rem;
    font-size: max(16px, 0.875rem);
}

/* Mobile Native Feel: Select and Textarea with 16px font */
select.form-control,
select.form-select,
textarea.form-control {
    font-size: max(16px, 1rem);
}

/* Form Select */
.form-select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: max(16px, 1rem);
    font-family: inherit;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background-color: var(--white);
    color: var(--dark-color);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 16px 12px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group {
    position: relative;
}

.input-group .form-control {
    padding-right: 3rem;
}

.input-group-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    /* Mobile Native Feel: Minimum touch target (44px Apple guideline) */
    min-height: 44px;
    /* Mobile Native Feel: Disable text selection on buttons */
    -webkit-user-select: none;
    user-select: none;
}

.btn:hover {
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--success-dark) 0%, var(--success-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--white);
}

.btn-outline-secondary {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline-secondary:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
    color: var(--gray-600);
    /* Mobile Native Feel: Minimum touch target for icon buttons */
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--dark-color);
}

/* ===== Checkboxes & Radio - Mobile Friendly ===== */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
    /* Mobile Native Feel: Larger touch target */
    min-width: 20px;
    min-height: 20px;
}

/* Checkbox label wrapper for larger touch area */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin: -0.5rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
}

.form-check:hover {
    background: var(--gray-50);
}

.form-check-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Supplier checklist container */
.supplier-checklist {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    background: var(--gray-50);
}

.supplier-checklist .form-check {
    margin: 0.25rem 0;
}

/* ===== Cards ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: none;
    overflow: visible; /* Changed from hidden to show dashed borders properly */
    resize: none; /* Prevent resize handles */
}

.card-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.card-header > i:last-child {
    margin-right: auto; /* Push chevron to the left in RTL */
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ===== Stats Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.primary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.stat-card .stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.stat-card .stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-card .stat-icon.info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

.stat-card .stat-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.stat-card .stat-info {
    flex: 1;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark-color);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* ===== Tables ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.875rem;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Data table cell highlighting */
.data-table td.price-lowest {
    background-color: #d4edda !important;
    font-weight: 600;
}

.data-table td.price-highlight {
    background-color: #fff3cd !important;
}

/* ===== Actions Bar ===== */
.actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.actions-bar .search-box {
    flex: 1;
    max-width: 350px;
    min-width: 200px;
}

/* ===== DataTable Toolbar ===== */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-start {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Delete All Button */
.delete-all-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

.delete-all-btn .spinner-border-sm {
    width: 0.875rem;
    height: 0.875rem;
}

/* Export Dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

.export-btn .spinner-border-sm {
    width: 0.875rem;
    height: 0.875rem;
}

.export-btn .bi-chevron-down {
    margin-right: 0.25rem;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.export-dropdown.open .export-btn .bi-chevron-down {
    transform: rotate(180deg);
}

.export-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
    /* Mobile Native Feel: GPU acceleration for smooth animations */
    transform: translateZ(0);
    will-change: transform, opacity;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: right;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
    /* Mobile Native Feel: Minimum touch target */
    min-height: 44px;
}

.export-option:hover {
    background: var(--bg-secondary);
}

.export-option i {
    color: var(--success);
}

.toolbar-end {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ===== Search Box Base Styles ===== */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box > i.bi-search,
.search-box > i.bi {
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1rem;
    pointer-events: none;
    z-index: 2;
}

.search-box input,
.search-box input.form-control {
    width: 100%;
    padding-block: 0.625rem;
    padding-inline-start: 2.5rem;
    padding-inline-end: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.875rem;
    background: #fff;
    transition: all 0.2s ease;
}

.search-box input:focus,
.search-box input.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box input::placeholder,
.search-box input.form-control::placeholder {
    color: var(--gray-400);
}

.table-toolbar .search-box {
    min-width: 250px;
}

.table-toolbar .search-box .btn-clear {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-100);
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 5;
    width: 24px;
    height: 24px;
}

.table-toolbar .search-box .btn-clear:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.table-toolbar .search-box .btn-clear i {
    font-size: 0.75rem;
}

/* ضبط padding الـ input عند وجود زر clear */
.table-toolbar .search-box:has(.btn-clear) input {
    padding-left: 2.5rem;
}

.page-size-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-size-select .form-select {
    width: auto;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.items-info {
    color: var(--gray-600);
    font-size: 0.875rem;
    white-space: nowrap;
}

/* ===== Sort Button ===== */
.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: none;
    font-weight: 600;
    color: var(--gray-800);
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    white-space: nowrap;
}

.sort-btn:hover {
    color: var(--primary-color);
}

.sort-btn i {
    font-size: 0.75rem;
}

.sort-icon-inactive {
    opacity: 0.3;
}

/* ===== Empty State in Table ===== */
.data-table .empty-state {
    text-align: center;
    padding: 3rem 1rem !important;
    color: var(--gray-500);
}

.data-table .empty-state i {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 1rem;
    display: block;
}

.data-table .empty-state p {
    margin: 0;
}

.data-table .empty-state .spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* ===== Import Section ===== */
.import-info-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.import-info-box .info-icon {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.import-info-box .info-content h4 {
    margin: 0 0 0.75rem 0;
    color: var(--gray-800);
    font-size: 1rem;
}

.import-info-box .info-content ol {
    margin: 0;
    padding-right: 1.25rem;
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.8;
}

.import-info-box .info-content ol li {
    margin-bottom: 0.25rem;
}

.import-info-box kbd {
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8rem;
    font-family: monospace;
}

/* Simple Import Hint */
.import-hint {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.import-hint i {
    color: var(--primary-color);
    font-size: 1rem;
}

.import-hint strong {
    color: var(--gray-800);
}

.import-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.paste-area {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    background: var(--gray-50);
    border: 2px dashed var(--gray-300);
    transition: all 0.3s ease;
    line-height: 1.6;
}

.paste-area:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.paste-area::placeholder {
    color: var(--gray-500);
    line-height: 1.8;
}

.preview-section {
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 1rem;
    border: 1px solid var(--gray-200);
}

.preview-section h4 {
    color: var(--gray-800);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Table Pagination ===== */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 1rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled):not(.active) {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.pagination-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-color: transparent;
    color: white;
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 0 0.5rem;
    color: var(--gray-500);
}

/* ===== Action Bar ===== */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--gray-300);
    border-radius: 26px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--success-color) 0%, #16a34a 100%);
}

.toggle-input:checked + .toggle-slider::before {
    right: calc(100% - 23px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--gray-700);
}

/* ===== Modal ===== */
/* Modal Backdrop - Blazor Style */
.modal-backdrop {
    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: 2000;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Legacy Modal Overlay Style */
.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: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
}

.modal-close:hover {
    color: var(--dark-color);
}

.modal-body {
    padding: 1.5rem;
    /* Mobile Native Feel: Smooth scrolling for modal content */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ===== Alerts ===== */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-dark);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: #0e7490;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-primary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray-400);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.empty-state h3 {
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-400);
    margin: 0;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

/* ===== Header Actions ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ===== User Menu ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-info {
    text-align: right;
}

.user-info .user-name {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.875rem;
}

.user-info .user-role {
    font-size: 0.75rem;
    color: var(--gray-600);
}

/* ===== Sidebar Overlay (Mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Loading Spinner ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        right: -100%;
        width: 280px;
        transition: right 0.3s ease;
    }
    
    .admin-sidebar.active {
        right: 0;
    }
    
    .admin-main {
        margin-right: 0 !important;
        width: 100%;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .admin-header {
        padding: 0.75rem 1rem;
    }
    
    .admin-header h1 {
        font-size: 1rem;
    }
    
    .admin-content {
        padding: 1rem;
    }
    
    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Table Toolbar Mobile */
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .toolbar-start,
    .toolbar-end {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .toolbar-start {
        flex-direction: column;
    }
    
    .table-toolbar .search-box {
        min-width: 100%;
        width: 100%;
    }
    
    .delete-all-btn,
    .export-btn {
        width: 100%;
        justify-content: center;
    }
    
    .items-info {
        display: none;
    }
    
    .page-size-select {
        width: 100%;
        justify-content: center;
    }
    
    /* Pagination Mobile */
    .table-pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.8125rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    .sidebar-close {
        display: block !important;
    }
    
    .login-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* NOTE: Utility classes are defined in utilities.css */

/* ===== Blazor Specific ===== */
#blazor-error-ui {
    background: var(--danger-color);
    color: var(--white);
    padding: 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: none;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--success-color);
}

.invalid {
    border-color: var(--danger-color);
}

.validation-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Remove Blazor default nav styles override */
.nav-link {
    color: inherit;
}

/* ========================================
   Shared Components Styles
   (مشترك بين جميع الصفحات)
   ======================================== */

/* ===== Data Table Code Style ===== */
.data-table code {
    background: var(--gray-200);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary-light {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.btn-primary-light:hover {
    background: rgba(37, 99, 235, 0.2);
}

.btn-danger-light {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.btn-danger-light:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-success-light {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.btn-success-light:hover {
    background: rgba(16, 185, 129, 0.2);
}

.btn-warning-light {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.btn-warning-light:hover {
    background: rgba(245, 158, 11, 0.2);
}

.btn-info-light {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
}

.btn-info-light:hover {
    background: rgba(14, 165, 233, 0.2);
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--gray-200);
    border-radius: 13px;
    transition: all 200ms ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: 50%;
    transition: all 200ms ease;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
}

.toggle-switch input:checked + .toggle-slider::after {
    right: calc(100% - 23px);
}

.toggle-label {
    font-weight: 500;
    color: var(--gray-800);
}

/* ===== Import Section ===== */
.import-info-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #93c5fd;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    animation: fadeIn 0.3s ease;
}

.info-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.info-content h4 {
    color: #1e40af;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
}

.info-content ol {
    margin: 0;
    padding-right: 1.25rem;
    color: #1e3a8a;
    font-size: 0.9rem;
    line-height: 1.8;
}

.info-content kbd {
    background: var(--white);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    border: 1px solid #93c5fd;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #1e40af;
    box-shadow: var(--shadow-sm);
}

.paste-area {
    font-family: 'Tajawal', monospace;
    resize: vertical;
    min-height: 120px;
}

.preview-section {
    border-top: 1px dashed var(--gray-200);
    padding-top: 1.5rem;
}

/* ===== Excel Import Section ===== */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--gray-50);
    box-sizing: border-box;
    display: block; /* Ensure it's a block element */
    outline: none; /* Remove focus outline */
}

.upload-area:focus,
.upload-area:focus-visible {
    outline: none;
    border-color: var(--primary-color);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-area i {
    font-size: 3rem;
    color: var(--primary-color);
    display: block;
    margin-bottom: 1rem;
}

.upload-area h4 {
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0;
}

/* Column Mapping */
.column-mapping-section h4 {
    color: var(--gray-800);
    margin: 0;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.mapping-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mapping-row .form-label {
    font-weight: 600;
    color: var(--gray-700);
    margin: 0;
}

.mapping-row .form-label .required {
    color: var(--danger-color);
}

/* Preview Table */
.preview-table {
    font-size: 0.875rem;
}

.preview-table th,
.preview-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

.preview-table input[type="text"],
.preview-table input[type="number"] {
    padding: 0.375rem 0.5rem;
    font-size: 0.85rem;
}

.preview-table .row-error {
    background-color: #fef2f2;
}

.preview-table .row-warning {
    background-color: #fefce8;
}

.preview-stats {
    display: flex;
    gap: 0.5rem;
}

/* Preview Pagination */
.preview-pagination-info {
    font-size: 0.875rem;
}

.preview-pagination {
    display: flex;
    justify-content: center;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-controls .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.page-indicator {
    background: var(--primary);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

/* Preview Action Buttons */
.preview-table .action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
}

.preview-table .btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-table .btn-icon.btn-edit {
    background: #dbeafe;
    color: #1d4ed8;
}

.preview-table .btn-icon.btn-edit:hover {
    background: #1d4ed8;
    color: white;
}

.preview-table .btn-icon.btn-delete {
    background: #fee2e2;
    color: #dc2626;
}

.preview-table .btn-icon.btn-delete:hover {
    background: #dc2626;
    color: white;
}

/* Small Modal */
.modal.modal-sm {
    max-width: 400px;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.status-badge.status-success {
    background: #dcfce7;
    color: #166534;
}

.status-badge.status-warning {
    background: #fef9c3;
    color: #854d0e;
}

.status-badge.status-error {
    background: #fef2f2;
    color: #991b1b;
}

/* Progress Bar */
.progress-container {
    text-align: center;
}

.progress-bar-wrapper {
    background: var(--gray-200);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-bar-animated {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--primary-color));
    background-size: 200% 100%;
    animation: progressAnimation 1.5s linear infinite;
}

@keyframes progressAnimation {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-text {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Import Actions */
.import-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Form Control Small */
.form-control-sm {
    padding: 0.375rem 0.5rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* ===== Responsive Action Buttons ===== */
@media (max-width: 768px) {
    .action-buttons {
        gap: 0.375rem;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
    
    .data-table code {
        font-size: 0.75rem;
        padding: 0.125rem 0.375rem;
    }
    
    .import-info-box {
        flex-direction: column;
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .info-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .upload-area i {
        font-size: 2rem;
    }
    
    .mapping-grid {
        grid-template-columns: 1fr;
    }
    
    .preview-table {
        font-size: 0.75rem;
    }
    
    .preview-table th,
    .preview-table td {
        padding: 0.375rem 0.5rem;
    }
}

@media (max-width: 400px) {
    .btn-icon {
        width: 28px;
        height: 28px;
    }
}

/* ===== Import Jobs Panel (عمليات الاستيراد) ===== */
.import-jobs-panel {
    border: 1px solid var(--info-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.import-jobs-panel .card-header {
    background: linear-gradient(135deg, var(--info-color), #0284c7);
    color: white;
    border: none;
}

.import-jobs-panel .card-header:hover {
    background: linear-gradient(135deg, #0284c7, var(--info-color));
}

.spin-animation {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.job-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    transition: background-color var(--transition-fast);
}

.job-item:last-child {
    border-bottom: none;
}

.job-item:hover {
    background-color: var(--gray-50);
}

/* Job Status Borders */
.job-pending {
    border-right: 4px solid var(--gray-400);
}

.job-processing {
    border-right: 4px solid var(--primary-color);
    background-color: rgba(37, 99, 235, 0.03);
}

.job-completed {
    border-right: 4px solid var(--success-color);
    background-color: rgba(16, 185, 129, 0.03);
}

.job-failed {
    border-right: 4px solid var(--danger-color);
    background-color: rgba(239, 68, 68, 0.03);
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.job-id {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.job-time {
    font-size: 0.8rem;
    color: var(--gray-600);
    background: var(--gray-100);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.job-progress {
    margin-bottom: 0.75rem;
}

.job-progress .job-progress-bar-wrapper {
    height: 12px;
    background: #e2e8f0 !important;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0.375rem;
}

.job-progress .job-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa) !important;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.job-progress .job-progress-bar.job-bar-success {
    background: linear-gradient(90deg, #10b981, #34d399) !important;
}

.job-progress .job-progress-bar.job-bar-danger {
    background: linear-gradient(90deg, #ef4444, #f87171) !important;
}

/* Processing animation */
.job-processing .job-progress .job-progress-bar {
    background: linear-gradient(90deg, #3b82f6, #60a5fa) !important;
    animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.job-progress .progress-text {
    font-size: 0.8rem;
    color: var(--gray-600);
    text-align: left;
    direction: ltr;
}

.job-details {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.job-details .badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
}

.job-message {
    font-size: 0.85rem;
    color: var(--gray-700);
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border-right: 3px solid var(--gray-300);
}

/* Job Status Colors */
.job-completed .job-message {
    border-right-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.job-failed .job-message {
    border-right-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.05);
}

/* Badge in Import Header */
.import-jobs-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

/* ========================================
   Enhanced Mobile Responsive Styles
   ======================================== */

/* ===== Tablet (max-width: 992px) ===== */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 240px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal {
        width: 90%;
        max-width: 500px;
    }
}

/* ===== Mobile (max-width: 768px) - Enhanced ===== */
@media (max-width: 768px) {
    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile Sidebar */
    .admin-sidebar {
        width: 85%;
        max-width: 300px;
        right: -100%;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
    }
    
    .admin-sidebar.active {
        right: 0;
    }
    
    .sidebar-close {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
    }
    
    /* Mobile Header */
    .admin-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .admin-header h1 {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 45%;
    }
    
    .admin-header h1 i {
        display: none;
    }
    
    .menu-toggle {
        display: flex !important;
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    /* User Menu Mobile */
    .user-menu {
        gap: 0.5rem;
    }
    
    .user-info {
        display: none;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    /* Content Area */
    .admin-content {
        padding: 0.75rem;
    }
    
    /* Cards */
    .card {
        border-radius: var(--radius-md);
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 0.875rem;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.375rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.75rem;
    }
    
    /* Actions Bar */
    .actions-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .actions-bar .search-box {
        width: 100%;
        order: 1;
    }
    
    .actions-bar .btn {
        width: 100%;
        justify-content: center;
        order: 2;
    }
    
    /* Tables - Horizontal Scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    
    .data-table {
        min-width: 600px;
        font-size: 0.825rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Removed sticky first column - was causing overlap issues */
    
    /* Action Buttons in Table */
    .action-buttons {
        gap: 0.25rem;
    }
    
    .action-buttons .btn-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
    
    /* Pagination */
    .table-pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.375rem;
        padding: 0.75rem;
    }
    
    .pagination-btn {
        min-width: 34px;
        height: 34px;
        font-size: 0.8125rem;
    }
    
    .pagination-btn span {
        display: none;
    }
    
    .pagination-btn i {
        margin: 0 !important;
    }
    
    /* Modal */
    .modal-backdrop {
        padding: 0.5rem;
        align-items: flex-end;
    }
    
    .modal {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(90vh - 140px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }
    
    .form-control {
        padding: 0.625rem 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Search Box */
    .search-box {
        min-width: unset;
        width: 100%;
    }
    
    .search-box input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn i {
        font-size: 1rem;
    }
    
    /* Empty State */
    .empty-state i {
        font-size: 3rem;
    }
    
    .empty-state p {
        font-size: 0.9rem;
    }
    
    /* Import Section */
    .upload-area {
        padding: 1.5rem 1rem;
    }
    
    .upload-area i {
        font-size: 2.5rem;
    }
    
    .upload-area h4 {
        font-size: 0.95rem;
    }
    
    /* Column Mapping */
    .mapping-grid {
        grid-template-columns: 1fr;
    }
    
    .mapping-row {
        flex-direction: column;
        gap: 0.375rem;
    }
    
    /* Import Actions */
    .import-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .import-actions .btn {
        width: 100%;
    }
    
    /* Jobs Panel */
    .job-item {
        padding: 0.75rem;
    }
    
    .job-header {
        font-size: 0.8rem;
    }
    
    .job-details .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Toggle Switch */
    .toggle-switch {
        flex-wrap: wrap;
    }
    
    /* Badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Loading Overlay */
    .loading-overlay .loading-content p {
        font-size: 0.9rem;
    }
}

/* ===== Small Mobile (max-width: 480px) - Enhanced ===== */
@media (max-width: 480px) {
    /* Stats Single Column */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Header Title Hidden */
    .admin-header h1 {
        font-size: 0.875rem;
        max-width: 35%;
    }
    
    /* Smaller Cards */
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.25rem;
    }
    
    /* Table Font Size */
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.375rem;
    }
    
    /* Compact Action Buttons */
    .action-buttons .btn-icon {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }
    
    .action-buttons .btn-icon i {
        font-size: 0.75rem;
    }
    
    /* Modal Full Width */
    .modal {
        max-height: 95vh;
    }
    
    .modal-body {
        max-height: calc(95vh - 130px);
    }
    
    /* Card Header */
    .card-header {
        padding: 0.625rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .card-header .badge {
        font-size: 0.65rem;
    }
    
    /* Preview Table */
    .preview-table {
        min-width: 500px;
    }
}

/* ===== Extra Small (max-width: 360px) ===== */
@media (max-width: 360px) {
    .admin-content {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 0.5rem;
    }
    
    .admin-header h1 {
        display: none;
    }
    
    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
}

/* ===== Touch Device Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .pagination-btn,
    .action-buttons .btn-icon {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control,
    .search-box input {
        min-height: 44px;
    }
    
    /* Remove hover effects */
    .btn:hover,
    .card:hover {
        transform: none;
    }
    
    /* Active states for touch */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    /* Disable text selection on interactive elements */
    .btn,
    .pagination-btn,
    .nav-link {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ===== Landscape Mobile ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .modal {
        max-height: 85vh;
        border-radius: var(--radius-lg);
    }
    
    .modal-body {
        max-height: calc(85vh - 140px);
    }
    
    .admin-sidebar {
        max-width: 260px;
    }
}

/* ===== Safe Area Support (Notch devices) ===== */
@supports (padding: max(0px)) {
    .admin-header {
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }
    
    .admin-sidebar {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .modal-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ===== Print Styles (Hide unnecessary elements) ===== */
@media print {
    .admin-sidebar,
    .admin-header,
    .menu-toggle,
    .action-buttons,
    .actions-bar,
    .table-pagination,
    .modal-backdrop {
        display: none !important;
    }
    
    .admin-main {
        margin: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ===== Mobile Native Feel Utilities ===== */

/* Scrollable containers with native feel */
.scrollable,
.scroll-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Hide scrollbar but keep functionality */
.scrollbar-hidden {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hidden::-webkit-scrollbar {
    display: none;
}

/* Clickable elements with larger touch area */
.touch-target {
    position: relative;
}

.touch-target::before {
    content: '';
    position: absolute;
    inset: -8px;
}

/* Prevent text selection on interactive elements */
.no-select {
    -webkit-user-select: none;
    user-select: none;
}

/* Force text selection (for copyable content) */
.selectable {
    -webkit-user-select: text;
    user-select: text;
}

/* GPU accelerated animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Active/pressed state for touch feedback */
.touchable:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Pull-to-refresh prevention on specific containers */
.no-pull-refresh {
    overscroll-behavior-y: contain;
}

/* ===== PWA Install Prompt - Modern Bottom Sheet ===== */
.pwa-install-prompt {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pwa-install-prompt.show {
    opacity: 1;
}

.pwa-install-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pwa-install-sheet {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: 24px 24px 0 0;
    padding: 12px 24px 32px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
}

.pwa-install-prompt.show .pwa-install-sheet {
    transform: translateY(0);
}

.pwa-install-handle {
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.pwa-install-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.pwa-install-icon img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(37, 99, 235, 0.1);
    animation: pwaPulse 2s ease-in-out infinite;
}

@keyframes pwaPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.pwa-install-icon svg {
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.pwa-install-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
    text-align: center;
    margin: 0 0 8px;
}

.pwa-install-desc {
    font-size: 0.95rem;
    color: var(--gray-600);
    text-align: center;
    margin: 0 0 20px;
    line-height: 1.6;
}

.pwa-install-features {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
}

.pwa-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.pwa-feature i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.pwa-feature span {
    font-size: 0.8rem;
    color: var(--gray-600);
}

.pwa-install-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-btn-install {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Tajawal', sans-serif;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.pwa-btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.pwa-btn-install:active {
    transform: translateY(0);
}

.pwa-btn-install i {
    font-size: 1.2rem;
}

.pwa-btn-dismiss {
    width: 100%;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Tajawal', sans-serif;
    color: var(--gray-600);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.pwa-btn-dismiss:hover {
    color: var(--gray-800);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .pwa-install-sheet {
        border-radius: 20px 20px 0 0;
        padding: 10px 20px 28px;
    }
    
    .pwa-install-title {
        font-size: 1.3rem;
    }
    
    .pwa-install-features {
        gap: 16px;
    }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pwa-install-sheet {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}
/* ========================================
   AlertStrip Component - Global Styles
   مكون التنبيهات المتجاوب
   ======================================== */

/* === الحاوية الرئيسية === */
.alert-strip {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

/* === رأس المكون === */
.alert-strip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.alert-strip-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-strip-icon {
    font-size: 1.2rem;
}

.alert-strip-header .badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 20px;
}

/* === جسم المكون === */
.alert-strip-body {
    padding: 0;
}

/* === حالة التحميل === */
.alert-strip-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    padding: 2rem;
    color: var(--gray-500);
    gap: 0.5rem;
}

/* === حالة فارغة === */
.alert-strip-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--gray-500);
    text-align: center;
    gap: 0.5rem;
}

.alert-strip-empty i {
    font-size: 2rem;
    color: var(--success-color);
}

/* === الجدول (Desktop) === */
.alert-strip-table-wrapper {
    overflow-x: auto;
}

.alert-strip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: auto;
}

.alert-strip-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid #e2e8f0;
}

.alert-strip-table th {
    padding: 0.75rem 1rem;
    text-align: right;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
    font-size: 0.8125rem;
}

.alert-strip-table td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.alert-strip-table tbody tr:last-child td {
    border-bottom: none;
}

.alert-strip-table tbody tr:hover {
    background: var(--gray-50);
}

/* === أعمدة الجدول === */
.alert-strip-table .col-name {
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-strip-table .col-amount {
    min-width: 120px;
    font-weight: 600;
    color: var(--danger-color);
    white-space: nowrap;
}

.alert-strip-table .col-days {
    min-width: 80px;
    white-space: nowrap;
}

.alert-strip-table .col-risk {
    min-width: 100px;
}

.alert-strip-table .col-actions {
    min-width: 100px;
}

/* === مؤشر الخطورة === */
.risk-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.risk-indicator.risk-high {
    background: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.risk-indicator.risk-medium {
    background: var(--warning-color);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.risk-indicator.risk-low {
    background: var(--info-color);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

/* === اسم العميل === */
.customer-name-text {
    font-weight: 500;
    color: var(--dark-color);
}

/* === شارة الخطورة === */
.risk-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.risk-badge.risk-high {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.risk-badge.risk-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.risk-badge.risk-low {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

/* === أيقونات الإجراءات === */
.action-icons {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.action-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.8rem;
}

.action-icon.call {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.action-icon.call:hover {
    background: var(--primary-color);
    color: var(--white);
}

.action-icon.whatsapp {
    background: rgba(37, 211, 102, 0.1);
    color: #25d366;
}

.action-icon.whatsapp:hover {
    background: #25d366;
    color: var(--white);
}

.action-icon.details {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.action-icon.details:hover {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

/* === عرض الكروت (Mobile) === */
.alert-strip-cards {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.alert-strip-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 1rem;
    border-right: 4px solid var(--gray-300);
}

.alert-strip-card.alert-level-high {
    border-right-color: var(--danger-color);
    background: linear-gradient(to left, rgba(239, 68, 68, 0.03), transparent);
}

.alert-strip-card.alert-level-medium {
    border-right-color: var(--warning-color);
    background: linear-gradient(to left, rgba(245, 158, 11, 0.03), transparent);
}

.alert-strip-card.alert-level-low {
    border-right-color: var(--info-color);
    background: linear-gradient(to left, rgba(6, 182, 212, 0.03), transparent);
}

/* === صف الكارت === */
.alert-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    border-bottom: 1px dashed var(--gray-100);
}

.alert-card-row:last-of-type {
    border-bottom: none;
}

.alert-card-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-weight: 500;
}

.alert-card-value {
    font-size: 0.875rem;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === إجراءات الكارت === */
.alert-card-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
}

.alert-card-actions .action-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
}

/* === ذيل المكون (عرض المزيد) === */
.alert-strip-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gray-100);
    text-align: center;
}

.btn-show-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    color: var(--gray-700);
    border: none;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-show-more:hover {
    background: var(--gray-200);
    color: var(--dark-color);
}

/* === Responsive: Desktop/Mobile toggle === */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    .alert-strip-cards {
        display: flex;
    }
    
    .alert-strip-header {
        padding: 0.875rem 1rem;
    }
    
    .alert-strip-header h3 {
        font-size: 0.9375rem;
    }
}

/* ===== Rating Badge - Professional Design (Global) ===== */
/* Used for performance-grade, credit-score, and any rating display */
.rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.rating-badge .rating-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.25);
    color: inherit;
    line-height: 1;
}

/* Rating Grade Colors */
.rating-badge.grade-a {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.rating-badge.grade-b {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.rating-badge.grade-c {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.rating-badge.grade-d {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.3);
}

.rating-badge.grade-f {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.rating-badge.grade-i {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
    box-shadow: 0 2px 6px rgba(107, 114, 128, 0.3);
}

/* Compact variant for tables and cards */
.rating-badge.compact {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

.rating-badge.compact .rating-letter {
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
}