/* ╔══════════════════════════════════════════════════════════╗
   ║  Secure Staff Tracker — Premium Design System           ║
   ║  Mobile-first responsive with RTL support               ║
   ╚══════════════════════════════════════════════════════════╝ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Cairo:wght@400;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);
    --accent: #06b6d4;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #273548;
    --bg-surface: #334155;
    --bg-input: #1e293b;
    --border: #334155;
    --border-light: #475569;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --radius: 16px;
    --radius-lg: 24px;
    --radius-sm: 10px;
    --radius-full: 9999px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px var(--primary-glow);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 260px;
    --font-en: 'Inter', sans-serif;
    --font-ar: 'Cairo', sans-serif;
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    max-width: 100vw;
    overflow-x: hidden;
}
body {
    font-family: var(--font-en);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

body[dir="rtl"] {
    font-family: var(--font-ar);
}

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

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Layout ────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

body[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand-icon i { font-size: 20px; color: #fff; }

.sidebar-brand-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
}

.sidebar-brand-sub {
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px; /* for scrollbar */
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
body[dir="rtl"] .sidebar-nav { padding-right: 0; padding-left: 4px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg-surface);
}

.nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 16px var(--primary-glow);
}

.nav-link i { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.sidebar-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}

.sidebar-user-name { font-weight: 600; font-size: 14px; color: var(--text); }
.sidebar-user-role { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

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

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
    min-width: 0; /* Prevents flex bounds collapsing */
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
}

body[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
    max-width: calc(100vw - var(--sidebar-width));
}

.page-content { max-width: 1200px; margin: 0 auto; width: 100%; overflow-x: hidden; }

/* ─── Mobile Header ─────────────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    z-index: 99;
}

.mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-header-brand i { font-size: 22px; color: var(--primary-light); }
.mobile-header-brand span { font-weight: 800; font-size: 18px; color: var(--text); }

.btn-menu {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-menu:hover { background: var(--bg-surface); }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.card-hover:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

/* ─── Stats Cards ───────────────────────────────────────── */
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.stat-card:hover { border-color: var(--border-light); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.info    { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.stat-icon.primary { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.stat-icon.danger  { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px var(--primary-glow); }

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}
.btn-success:hover { transform: translateY(-1px); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Action Buttons (Dashboard) ────────────────────────── */
.action-btn {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: start;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 130px;
}

.action-btn:hover:not(:disabled) { transform: translateY(-4px); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--bg-surface) !important; }

.action-btn .action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.action-btn:disabled .action-icon {
    background: var(--bg-card);
    color: var(--text-muted);
}

.action-btn .action-label {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}

.action-btn:disabled .action-label { color: var(--text-secondary); }

.action-btn .action-glow {
    position: absolute;
    right: -20px;
    top: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: transform 0.5s ease;
}
.action-btn:hover:not(:disabled) .action-glow { transform: scale(2); }

.action-emerald { background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3); }
.action-amber   { background: linear-gradient(135deg, #fbbf24, #d97706); box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3); }
.action-blue    { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3); }
.action-rose    { background: linear-gradient(135deg, #fb7185, #e11d48); box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3); }

/* ─── Form Elements ─────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

body[dir="rtl"] select.form-control {
    background-position: left 12px center;
    padding-right: 16px;
    padding-left: 36px;
}

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

/* ─── Table ─────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px; /* Force table to retain shape and scroll instead of collapsing text */
}

thead { background: var(--bg-surface); }

th {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: start;
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-top: 1px solid var(--border);
}

tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-card-hover); }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger  { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info    { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-primary { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.badge-purple  { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

/* ─── Modal ─────────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 200;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-backdrop.show { display: flex; }

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    animation: modalSlideUp 0.3s ease;
}

.modal-content.wide { max-width: 700px; }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title { font-size: 22px; font-weight: 700; }

/* ─── Dropdown Menu ─────────────────────────────────────── */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background: var(--bg-card);
    min-width: 160px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 1000;
    overflow: hidden;
    margin-top: 4px;
}
body[dir="rtl"] .dropdown-content {
    right: auto;
    left: 0;
}
.dropdown-content a, .dropdown-content button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    width: 100%;
    text-align: start;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.dropdown-content a:hover, .dropdown-content button:hover {
    background: var(--bg-surface);
}
.dropdown:hover .dropdown-content {
    display: block;
}
.dropdown:focus-within .dropdown-content {
    display: block;
}

.modal-close {
    width: 36px; height: 36px;
    border: none; background: var(--bg-surface);
    color: var(--text-secondary); cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ─── Toast ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body[dir="rtl"] .toast-container { right: auto; left: 20px; }

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
}

.toast.success { background: linear-gradient(135deg, var(--success), #059669); }
.toast.error   { background: linear-gradient(135deg, var(--danger), #dc2626); }
.toast.warning { background: linear-gradient(135deg, var(--warning), #d97706); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

body[dir="rtl"] .toast {
    animation-name: toastInRtl;
}
@keyframes toastInRtl {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ─── Status Indicator ──────────────────────────────────── */
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.status-dot.green  { background: var(--success); }
.status-dot.amber  { background: var(--warning); }
.status-dot.red    { background: var(--danger); }
.status-dot.muted  { background: var(--text-muted); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── User Item ─────────────────────────────────────────── */
.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.user-item:hover { background: var(--bg-card-hover); }
.user-item:last-child { border-bottom: none; }

.user-info { display: flex; align-items: center; gap: 14px; }

.user-avatar {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; color: #fff;
    flex-shrink: 0;
}

.user-name { font-weight: 600; font-size: 15px; color: var(--text); }
.user-username { font-size: 13px; color: var(--text-muted); }
.user-actions { display: flex; align-items: center; gap: 10px; }

/* ─── Activity Log Item ─────────────────────────────────── */
.log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.log-item:hover { background: var(--bg-card-hover); }
.log-item:last-child { border-bottom: none; }

.log-info { display: flex; align-items: center; gap: 14px; }

.log-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.log-icon.check-in  { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.log-icon.check-out { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.log-icon.break     { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.log-type { font-weight: 600; font-size: 14px; color: var(--text); text-transform: capitalize; }
.log-time { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.log-meta { text-align: end; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

/* ─── Branch Card ───────────────────────────────────────── */
.branch-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}
.branch-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--border-light); }

.branch-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    transition: transform 0.3s;
}
.branch-card:hover .branch-icon { transform: scale(1.1); }

/* ─── Task Card ─────────────────────────────────────────── */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: var(--transition);
}
.task-card:hover { box-shadow: var(--shadow); border-color: var(--border-light); }

/* ─── Approval Card ─────────────────────────────────────── */
.approval-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    transition: var(--transition);
}

/* ─── Alert Banner ──────────────────────────────────────── */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}
.alert-warning { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); color: var(--warning); }

/* ─── Login Page ────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
}

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.login-form-container { width: 100%; max-width: 420px; }

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo-icon {
    width: 64px; height: 64px;
    margin: 0 auto 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-glow);
}
.login-logo-icon i { font-size: 28px; color: #fff; }

.login-logo h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.login-logo .sub { font-size: 11px; letter-spacing: 4px; color: var(--accent); font-weight: 600; margin-top: 4px; }
.login-logo p { color: var(--text-muted); margin-top: 10px; font-size: 15px; }

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.login-card .form-control { height: 50px; border-radius: var(--radius-sm); }

.login-btn {
    width: 100%;
    height: 50px;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

.login-security {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.login-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary-dark), #312e81, #1e1b4b);
}

.login-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('https://images.unsplash.com/photo-1497366216548-37526070297c?w=1920&q=80') center/cover;
    opacity: 0.08;
}

.login-hero-content { position: relative; z-index: 1; max-width: 500px; text-align: center; }
.login-hero h2 { font-size: 40px; font-weight: 800; color: #fff; line-height: 1.2; margin-bottom: 32px; }

.login-features { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.login-feature {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    padding: 24px;
    text-align: start;
}
.login-feature i { font-size: 28px; color: #6ee7b7; margin-bottom: 14px; display: block; }
.login-feature h3 { font-weight: 700; color: #fff; font-size: 16px; margin-bottom: 6px; }
.login-feature p { font-size: 13px; color: rgba(255, 255, 255, 0.7); }

/* ─── Language Switcher ─────────────────────────────────── */
.lang-switch {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 150;
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px;
    box-shadow: var(--shadow);
}

body[dir="rtl"] .lang-switch { left: auto; right: 20px; }

.lang-btn {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    color: var(--text-muted);
}
.lang-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ─── QR Scanner ────────────────────────────────────────── */
.qr-scanner {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    border: 3px solid var(--primary-glow);
}

.qr-scanner video { width: 100%; height: 100%; object-fit: cover; }

/* ─── Biometric Animation ───────────────────────────────── */
.bio-scan {
    height: 200px;
    border-radius: var(--radius);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.bio-scan i { font-size: 56px; color: var(--primary-light); }

.bio-scan-line {
    position: absolute;
    left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%   { top: 10%; }
    50%  { top: 90%; }
    100% { top: 10%; }
}

/* ─── Verification Toggle ───────────────────────────────── */
.verify-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.verify-btn {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}
.verify-btn:hover { border-color: var(--primary); color: var(--text); }
.verify-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    box-shadow: 0 4px 16px var(--primary-glow);
}

/* ─── Map Container ─────────────────────────────────────── */
.map-wrapper {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: 0.3; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }

/* ─── Grid Helpers ──────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.flex-center { display: flex; align-items: center; gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }

/* ─── Page Animation ────────────────────────────────────── */
.page-enter { animation: fadeIn 0.4s ease; }

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

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    body[dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    body[dir="rtl"] .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }

    .mobile-header { display: flex; }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 76px 12px 24px;
        width: 100vw;
        max-width: 100vw !important;
        overflow-x: hidden;
    }

    .login-hero { display: none; }
    .login-form-side { padding: 24px 16px; }

    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    
    .flex-between { flex-direction: column; align-items: stretch; gap: 12px; }

    .approval-card { flex-direction: column; }
    .user-item { flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px 16px; }
    .user-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
    .log-item { flex-direction: column; align-items: flex-start; gap: 10px; }
    .log-meta { align-items: flex-start; }

    /* Cards */
    .card { padding: 16px; border-radius: var(--radius); }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-value { font-size: 22px; }
    .stat-icon { width: 42px; height: 42px; font-size: 18px; }

    /* Map fixes - controlled heights */
    #branch-map { height: 250px !important; }
    #branch-create-map { height: 200px !important; }
    .map-wrapper { border-radius: var(--radius-sm); }

    /* Modal full-screen on mobile */
    .modal-content {
        max-width: 100% !important;
        max-height: 95vh;
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 20px 16px;
        margin: auto 0 0 0;
    }
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal-content.wide { max-width: 100% !important; }
    .modal-title { font-size: 18px; }

    /* Branch form grid: stack on mobile */
    .branch-form-grid,
    .modal-content [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Action buttons */
    .action-btn { min-height: 100px; padding: 16px; border-radius: var(--radius); }
    .action-btn .action-icon { width: 40px; height: 40px; font-size: 18px; }
    .action-btn .action-label { font-size: 14px; }

    /* Table scroll */
    .table-container { border-radius: var(--radius); }
    th, td { padding: 10px 12px; font-size: 13px; }

    /* Badge smaller */
    .badge { font-size: 10px; padding: 3px 8px; }

    /* Branch card */
    .branch-card { padding: 16px; }

    /* h1 titles */
    h1 { font-size: 22px !important; }

    /* Toasts */
    .toast-container { right: 12px; left: 12px; top: 76px; }
    .toast { min-width: auto; width: 100%; font-size: 13px; }
    body[dir="rtl"] .toast-container { right: 12px; left: 12px; }

    /* Toggle labels */
    .toggle-switch span[style*="font-size:11px"] { display: none; }
}

@media (max-width: 480px) {
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .login-features { grid-template-columns: 1fr; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .main-content { padding: 72px 10px 20px; }

    /* Single-col action buttons on small phones */
    .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .action-btn { min-height: 90px; padding: 12px; gap: 10px; }
    .action-btn .action-label { font-size: 13px; }

    /* User item even more compact */
    .user-item { padding: 12px; }
    .user-avatar { width: 36px; height: 36px; font-size: 14px; }
    .user-name { font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════ */
/* ═══ MASTER CONTROL PANEL STYLES ═══════════════════════════ */
/* ═══════════════════════════════════════════════════════════ */

/* Master Sidebar Branding */
.sidebar-master { border-color: rgba(245, 158, 11, 0.2); }
.sidebar-master .sidebar-brand-icon.master-icon,
.master-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.25) !important;
}
.sidebar-master .nav-link.active {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25) !important;
}
.master-avatar {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

/* Stats Grid (5 cols for master) */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

/* Company Card */
.company-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}
.company-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Subscription Expired Banner */
.subscription-expired-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}
.sub-expired-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.subscription-expired-banner h3 {
    font-size: 16px; font-weight: 700; color: var(--danger); margin-bottom: 4px;
}
.subscription-expired-banner p {
    font-size: 14px; color: var(--text-secondary);
}

/* Flex Between */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

/* Grid helpers */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Utility */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.p-0 { padding: 0 !important; }
.p-8 { padding: 32px !important; }
.text-center { text-align: center; }
.text-end { text-align: end; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.font-bold { font-weight: 700; }
.overflow-hidden { overflow: hidden; }
.block { display: block; }
.opacity-50 { opacity: 0.5; }
.flex-wrap { display: flex; flex-wrap: wrap; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

/* Responsive Helpers */
.hide-mobile { display: block; }
.show-mobile { display: none; }

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.4;
}
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Map Wrapper */
.map-wrapper { border-radius: var(--radius); overflow: hidden; }

/* Verification Options */
.verify-options { display: flex; gap: 12px; flex-wrap: wrap; }
.verify-btn {
    flex: 1;
    padding: 14px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    min-width: 120px;
}
.verify-btn:hover { border-color: var(--primary); color: var(--text); }
.verify-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}

/* QR Scanner */
.qr-scanner {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    position: relative;
}

/* Biometric Scan */
.bio-scan {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    position: relative;
}
.bio-scan i { font-size: 64px; color: var(--primary-light); }
.bio-scan-line {
    position: absolute;
    width: 80%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    animation: bioScan 2s ease-in-out infinite;
}
@keyframes bioScan {
    0%, 100% { top: 20%; }
    50% { top: 80%; }
}

/* Page Enter Animation */
.page-enter {
    animation: pageEnter 0.3s ease;
}
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══ PWA Install Banner ═══════════════════════════════════ */
.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    animation: pwaSlideDown 0.4s ease;
}
.pwa-install-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    max-width: 1200px;
    margin: 0 auto;
}
@keyframes pwaSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ─── Responsive Calendar ──────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
}
.calendar-label {
    text-align: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px;
}
.calendar-day {
    aspect-ratio: 1/1;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
    border: 1px solid var(--border);
    background: var(--bg-card);
}
.calendar-day:hover { transform: translateY(-2px); border-color: var(--border-light); }
.calendar-day.is-today { border-color: var(--primary); box-shadow: 0 0 15px var(--primary-glow); }
.calendar-day.day-weekend { background: var(--bg-surface); }
.calendar-day.day-absent { background: rgba(239, 68, 68, 0.05); }
.calendar-day.empty { border-style: dashed; background: transparent; }

@media (max-width: 768px) {
    .calendar-grid { gap: 6px; }
    .calendar-day { padding: 6px; border-radius: 8px; }
    .calendar-day span { font-size: 11px !important; }
    .calendar-day i { font-size: 10px !important; }
    .calendar-label { font-size: 10px; padding: 4px; }
}

@media (max-width: 480px) {
    .calendar-grid { gap: 4px; }
    .calendar-day { padding: 4px; border-radius: 6px; }
    .calendar-day .progress-bar-container { display: none; } /* Hide bars on tiny screens */
    .calendar-day div[style*="font-size:11px"] { font-size: 9px !important; }
    .main-content { padding: 76px 12px 24px; } /* Ensure header clearance */
}

/* ─── Global Responsive Fixes ───────────────────────────── */
@media (max-width: 768px) {
    .grid-stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .flex-between { flex-direction: column; align-items: stretch; }
    .flex-between select, .flex-between .btn { width: 100% !important; }
    .btn { width: 100%; } /* Cards button stack */
    .btn-sm { width: auto; }
}

@media (max-width: 400px) {
    .grid-4 { grid-template-columns: 1fr; } /* Stack actions on very small screens */
    .stat-card { flex-direction: column; text-align: center; }
    .stat-icon { margin: 0 auto; }
}

/* ─── Safe Area (notch phones) ─────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
    .mobile-header {
        padding-top: env(safe-area-inset-top);
        height: calc(64px + env(safe-area-inset-top));
    }
    .pwa-install-banner {
        padding-top: env(safe-area-inset-top);
    }
}

/* ─── Print ─────────────────────────────────────────────── */
@media print {
    .sidebar, .mobile-header, .lang-switch, .btn, .pwa-install-banner { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; color: #000; }
    .card, .table-container { border: 1px solid #ddd; }
}

