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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.25);

    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #06b6d4;
    --info-light: #ecfeff;

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --sidebar-text: #475569;
    --sidebar-text-hover: #4f46e5;
    --sidebar-active: #4f46e5;
    --sidebar-active-bg: #eef2ff;
    --sidebar-border: #e2e8f0;
    --sidebar-brand-title: #0f172a;
    --sidebar-section-title: #94a3b8;
    --sidebar-user-name: #0f172a;
    --sidebar-user-role: #64748b;

    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --sidebar-width: 260px;
    --navbar-height: 70px;
}

/* =====================================================================
   Reset & Base
   ===================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

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

/* =====================================================================
   Sidebar
   ===================================================================== */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 200;
    transition: transform 0.3s ease, background-color 0.25s ease, border-color 0.25s ease;
    border-left: 1px solid var(--sidebar-border);
    box-shadow: -2px 0 16px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

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

.brand-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h2 {
    font-size: 17px;
    font-weight: 800;
    color: var(--sidebar-brand-title);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.brand-text span {
    font-size: 11px;
    color: #6366f1;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--sidebar-section-title);
    padding: 10px 14px 4px 14px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

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

.nav-link.active {
    color: var(--sidebar-active);
    background: var(--sidebar-active-bg);
    border-right: 3px solid #6366f1;
}

.nav-link i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.admin-avatar-small {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background-color: #334155;
    border: 2px solid #6366f1;
}

.admin-info-small {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.admin-info-small .name {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--sidebar-user-name);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-info-small .role {
    font-size: 10.5px;
    color: var(--sidebar-user-role);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====================================================================
   Mobile Sidebar Overlay
   ===================================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}

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

/* =====================================================================
   Main Content Area
   ===================================================================== */
.app-main {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s ease;
    min-width: 0;
}

/* =====================================================================
   Top Navbar
   ===================================================================== */
.top-navbar {
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 150;
    gap: 12px;
}

/* Hamburger button — hidden on desktop */
.sidebar-toggle-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.navbar-title {
    flex: 1;
    min-width: 0;
}

.navbar-title h1 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.action-btn-circle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.action-btn-circle:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.badge-dot {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: var(--radius-full);
    border: 2px solid #fff;
}

/* =====================================================================
   Content Container
   ===================================================================== */
.content-container {
    padding: 24px;
    flex: 1;
    min-width: 0;
}

/* =====================================================================
   Responsive Grid Utilities
   ===================================================================== */

/* 2-column grid that collapses on mobile */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 2/3 + 1/3 split that collapses on tablet */
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* Auto-fit stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

/* Filter row */
.filter-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-row .filter-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
}

/* Action bar */
.action-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* Flex wrap row */
.flex-row-wrap {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* =====================================================================
   Dashboard KPI Cards
   ===================================================================== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 0;
}

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

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

.stat-icon-primary  { background: #eef2ff; color: #4f46e5; }
.stat-icon-success  { background: #ecfdf5; color: #10b981; }
.stat-icon-warning  { background: #fffbeb; color: #f59e0b; }
.stat-icon-danger   { background: #fef2f2; color: #ef4444; }
.stat-icon-info     { background: #ecfeff; color: #06b6d4; }
.stat-icon-purple   { background: #faf5ff; color: #a855f7; }

.stat-info {
    min-width: 0;
    flex: 1;
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.stat-info p {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====================================================================
   Quick Actions Banner
   ===================================================================== */
.quick-actions-bar {
    background: linear-gradient(90deg, #4f46e5 0%, #3730a3 100%);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.quick-actions-bar .qa-text h3 {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
}

.quick-actions-bar .qa-text p {
    font-size: 12px;
    opacity: 0.85;
    color: #fff;
    margin-top: 2px;
}

.quick-actions-bar .qa-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* =====================================================================
   Standard Content Card
   ===================================================================== */
.card-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    min-width: 0;
}

.card-header-flex {
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.card-body {
    padding: 22px;
}

/* =====================================================================
   Modern Tables
   ===================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 560px;
}

.app-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.app-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

.app-table tr:hover td {
    background-color: #fbfcfe;
}

/* =====================================================================
   Badges
   ===================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success   { background: var(--success-light); color: #065f46; }
.badge-danger    { background: var(--danger-light);  color: #991b1b; }
.badge-warning   { background: var(--warning-light); color: #92400e; }
.badge-info      { background: var(--info-light);    color: #155e75; }
.badge-primary   { background: var(--primary-light); color: #3730a3; }
.badge-secondary { background: #f1f5f9;              color: #475569; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #059669; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-outline  { background: #fff; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover  { background: #f8fafc; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }

/* =====================================================================
   Forms
   ===================================================================== */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 7px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 13.5px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-section-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =====================================================================
   User Pill / Avatar
   ===================================================================== */
.user-info-flex {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-avatar-round {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: #e2e8f0;
    flex-shrink: 0;
}

.user-name-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-sub-email {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====================================================================
   Map Containers
   ===================================================================== */
#liveMap, #historyMap {
    width: 100%;
    height: 580px;
    border-radius: var(--radius-lg);
    z-index: 10;
}

/* =====================================================================
   Checkbox Toggle
   ===================================================================== */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.toggle-row label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
}

/* =====================================================================
   Employee Details Page
   ===================================================================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

/* =====================================================================
   SelfAttendance / Webcam
   ===================================================================== */
.self-attendance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.webcam-box {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 4/3;
    margin: 0 auto 16px auto;
    background: #0f172a;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webcam-box video,
.webcam-box canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =====================================================================
   Live Map Layout
   ===================================================================== */
.livemap-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: start;
}

.livemap-sidebar {
    max-height: 640px;
    overflow-y: auto;
}

/* =====================================================================
   Notifications Page
   ===================================================================== */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* =====================================================================
   Responsive — Tablet (≤ 1100px)
   ===================================================================== */
@media (max-width: 1100px) {
    .livemap-layout {
        grid-template-columns: 1fr;
    }

    .livemap-sidebar {
        max-height: 400px;
    }

    #liveMap, #historyMap {
        height: 480px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* =====================================================================
   Responsive — Tablet/Landscape (≤ 992px) — Sidebar hidden
   ===================================================================== */
@media (max-width: 992px) {
    /* Hide sidebar off-canvas */
    .app-sidebar {
        transform: translateX(100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    }

    /* Remove sidebar margin */
    .app-main {
        margin-right: 0;
    }

    /* Show hamburger */
    .sidebar-toggle-btn {
        display: flex;
    }

    /* Dashboard 2-1 grid → 1 col */
    .grid-2-1 {
        grid-template-columns: 1fr;
    }

    /* Quick actions wrap */
    .quick-actions-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Self-attendance side-by-side → stacked */
    .self-attendance-grid {
        grid-template-columns: 1fr;
    }

    /* 2-col grid → 1 col */
    .grid-2col {
        grid-template-columns: 1fr;
    }

    /* Detail grid → 1 col */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    /* Navbar title font */
    .navbar-title h1 {
        font-size: 15px;
    }

    /* Content padding */
    .content-container {
        padding: 16px;
    }

    /* Map */
    #liveMap, #historyMap {
        height: 420px;
    }
}

/* =====================================================================
   Responsive — Mobile (≤ 640px)
   ===================================================================== */
@media (max-width: 640px) {
    .top-navbar {
        padding: 0 14px;
        gap: 8px;
    }

    .navbar-title h1 {
        font-size: 14px;
    }

    /* Hide some nav action labels on very small */
    .action-btn-circle {
        width: 36px;
        height: 36px;
    }

    .navbar-actions {
        gap: 6px;
    }

    .content-container {
        padding: 12px;
    }

    /* Stats grid → 2 columns on phone */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 12px;
    }

    .stat-icon-box {
        width: 44px;
        height: 44px;
        min-width: 44px;
        font-size: 18px;
    }

    .stat-info h3 {
        font-size: 20px;
    }

    .stat-info p {
        font-size: 11px;
    }

    .card-header-flex {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .card-body {
        padding: 16px;
    }

    /* Filter form stacked */
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-row .filter-controls {
        flex-direction: column;
    }

    /* Buttons full-width inside filter on mobile */
    .filter-row .btn {
        width: 100%;
        justify-content: center;
    }

    /* Quick actions */
    .quick-actions-bar .qa-buttons {
        width: 100%;
    }

    .quick-actions-bar .qa-buttons .btn {
        flex: 1;
        min-width: 0;
        font-size: 12px;
        padding: 8px 10px;
    }

    /* Table scroll hint */
    .table-responsive::after {
        content: '← اسحب لعرض المزيد';
        display: block;
        text-align: center;
        font-size: 11px;
        color: var(--text-muted);
        padding: 6px;
    }

    /* Map height */
    #liveMap, #historyMap {
        height: 320px;
    }

    /* Self attendance webcam */
    .webcam-box {
        max-width: 100%;
    }

    .card-box {
        margin-bottom: 16px;
    }
}

/* =====================================================================
   Responsive — Very small phones (≤ 400px)
   ===================================================================== */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 12px;
    }

    .navbar-title h1 {
        font-size: 12px;
    }

    .action-btn-circle {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
}

/* =====================================================================
   Dark Theme Styles
   ===================================================================== */
[data-theme="dark"] {
    --bg-main: #090d16;
    --bg-card: #131b2e;
    --bg-sidebar: #0e1526;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.25);
    --sidebar-border: #1e293b;
    --sidebar-brand-title: #ffffff;
    --sidebar-section-title: #64748b;
    --sidebar-user-name: #ffffff;
    --sidebar-user-role: #94a3b8;

    --border: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    --primary-light: #1e1b4b;
    --success-light: #064e3b;
    --warning-light: #451a03;
    --danger-light: #450a0a;
    --info-light: #083344;
}

[data-theme="dark"] .action-btn-circle {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border);
}

[data-theme="dark"] .action-btn-circle:hover {
    background: #1e293b;
    color: #6366f1;
    border-color: #6366f1;
}

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

[data-theme="dark"] .stat-card,
[data-theme="dark"] .card,
[data-theme="dark"] .card-box,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .table-card,
[data-theme="dark"] .emp-live-item {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border);
}

[data-theme="dark"] .card-header-flex {
    border-color: var(--border);
}

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

[data-theme="dark"] .form-control,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #090d16 !important;
    color: #f8fafc !important;
    border-color: #222f46 !important;
}

[data-theme="dark"] .app-table th {
    background: #0d1322;
    color: #94a3b8;
    border-color: var(--border);
}

[data-theme="dark"] .app-table td {
    border-color: var(--border);
    color: var(--text-main);
}

[data-theme="dark"] .app-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .badge-secondary {
    background: #1e293b;
    color: #cbd5e1;
}

[data-theme="dark"] .btn-outline {
    background: transparent;
    color: #cbd5e1;
    border-color: var(--border);
}

[data-theme="dark"] .btn-outline:hover {
    background: #1e293b;
    color: #fff;
    border-color: #6366f1;
}

[data-theme="dark"] .form-section-title {
    color: var(--text-main);
    border-color: var(--border);
}

[data-theme="dark"] .toggle-row label {
    color: var(--text-main);
}

[data-theme="dark"] .detail-value {
    color: var(--text-main);
}

/* SweetAlert2 Dark Theme */
[data-theme="dark"] .swal2-popup {
    background: #131b2e !important;
    color: #f8fafc !important;
    border: 1px solid #222f46 !important;
}

[data-theme="dark"] .swal2-title,
[data-theme="dark"] .swal2-html-container {
    color: #f8fafc !important;
}

/* =====================================================================
   LTR (English) Support
   ===================================================================== */
html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .app-sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.04);
    transform: none;
}

html[dir="ltr"] .app-main {
    margin-right: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

html[dir="ltr"] .nav-link.active {
    border-right: none;
    border-left: 3px solid #6366f1;
}

html[dir="ltr"] .nav-badge {
    margin-right: 0;
    margin-left: auto;
}

html[dir="ltr"] .badge-dot {
    left: auto;
    right: 6px;
}

@media (max-width: 992px) {
    html[dir="ltr"] .app-sidebar {
        transform: translateX(-100%);
    }

    html[dir="ltr"] .app-sidebar.open {
        transform: translateX(0);
    }

    html[dir="ltr"] .app-main {
        margin-left: 0;
    }
}

/* =====================================================================
   System / SignalR Connection Status Banner
   ===================================================================== */
.system-connection-banner {
    position: sticky;
    top: 0;
    z-index: 150;
    width: 100%;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 13.5px;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.system-connection-banner.warning {
    background: #fffbeb;
    color: #b45309;
    border-bottom: 1px solid #fde68a;
}

.system-connection-banner.danger {
    background: #fef2f2;
    color: #b91c1c;
    border-bottom: 1px solid #fecaca;
}

.system-connection-banner.success {
    background: #ecfdf5;
    color: #047857;
    border-bottom: 1px solid #a7f3d0;
}

[data-theme="dark"] .system-connection-banner.warning {
    background: #451a03;
    color: #fde68a;
    border-bottom-color: #78350f;
}

[data-theme="dark"] .system-connection-banner.danger {
/* =====================================================================
   Floating Connection Status Pill (Glassmorphism Floating Widget)
   ===================================================================== */
.floating-connection-pill {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    border-radius: 9999px;
    font-size: 13.5px;
    font-weight: 600;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.22), 0 6px 12px -4px rgba(0, 0, 0, 0.12);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: pillSlideUp 0.35s ease-out;
}

@keyframes pillSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.floating-connection-pill.warning {
    background: rgba(217, 119, 6, 0.94);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.floating-connection-pill.danger {
    background: rgba(220, 38, 38, 0.94);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.floating-connection-pill.success {
    background: rgba(16, 185, 129, 0.95);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.floating-connection-pill .pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffffff;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    animation: pulseDot 1.8s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes pulseDot {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

.floating-connection-pill .btn-floating-retry {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #ffffff;
    padding: 5px 14px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.floating-connection-pill .btn-floating-retry:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}


