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

:root {
    --bg-primary: #080c14;
    --bg-secondary: #0f172a;
    --bg-tertiary: #182238;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #94c83d;
    --primary-hover: #7ea933;
    --primary-glow: rgba(148, 200, 61, 0.35);
    
    --gold: #d4af37;
    --gold-hover: #b89628;
    --gold-glow: rgba(212, 175, 55, 0.35);
    --gold-bg: rgba(212, 175, 55, 0.1);
    
    --secondary: #d4af37;
    --accent: #94c83d;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #d4af37;
    --warning-bg: rgba(212, 175, 55, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    
    --border-color: rgba(212, 175, 55, 0.15);
    --border-hover: rgba(148, 200, 61, 0.35);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Inter', sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary: #94c83d;
    --primary-hover: #7ea933;
    --primary-glow: rgba(148, 200, 61, 0.2);
    --border-color: rgba(0, 0, 0, 0.06);
    --border-hover: rgba(0, 0, 0, 0.12);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ar);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
    transition: var(--transition);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-shrink: 0;
    transition: var(--transition);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.5rem 0;
}

.brand-logo-img {
    height: 52px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 10px rgba(148, 200, 61, 0.4)) drop-shadow(0 1px 3px rgba(255, 255, 255, 0.3));
    transition: var(--transition);
}

.brand-logo-img:hover {
    filter: drop-shadow(0 4px 18px rgba(148, 200, 61, 0.6)) drop-shadow(0 1px 4px rgba(255, 255, 255, 0.5));
    transform: scale(1.03);
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.logo-text {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1.1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(212, 175, 55, 0.06);
    border-color: rgba(212, 175, 55, 0.2);
    transform: translateX(-3px);
}

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(148, 200, 61, 0.15) 0%, rgba(212, 175, 55, 0.1) 100%);
    border: 1px solid rgba(148, 200, 61, 0.35);
    border-right: 4px solid var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(148, 200, 61, 0.15);
}

.nav-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

header {
    height: 80px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    transition: var(--transition);
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

/* User Profile Badge */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Dashboard Content Grid */
.content-wrapper {
    padding: 2.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

/* Stats Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: linear-gradient(145deg, var(--bg-secondary) 0%, rgba(24, 34, 56, 0.6) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--gold));
    opacity: 0.4;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4), 0 0 15px rgba(148, 200, 61, 0.15);
}

.stat-card:hover::before {
    opacity: 1;
    width: 6px;
}

.stat-card.pending-sign::before { background-color: var(--warning); }
.stat-card.pending-approve::before { background-color: var(--info); }
.stat-card.active-contracts::before { background-color: var(--success); }

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    font-family: var(--font-en);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-icon.primary { background-color: rgba(148, 200, 61, 0.15); color: var(--primary); }
.stat-icon.warning { background-color: var(--warning-bg); color: var(--warning); }
.stat-icon.info { background-color: var(--info-bg); color: var(--info); }
.stat-icon.success { background-color: var(--success-bg); color: var(--success); }

/* Common UI Components */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-ar);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #94c83d 0%, #7aa82f 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(148, 200, 61, 0.3);
    border: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #9fd642 0%, #85b833 100%);
    box-shadow: 0 6px 22px rgba(148, 200, 61, 0.45);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-secondary);
    border-color: var(--text-secondary);
}

.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-warning {
    background-color: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(212, 175, 55, 0.2);
}

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

.btn-success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background-color: var(--success);
    color: white;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* Badge Styles */
.badge {
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge-draft { background-color: var(--bg-tertiary); color: var(--text-secondary); }
.badge-pending-sign { background-color: var(--warning-bg); color: var(--warning); }
.badge-pending-approve { background-color: var(--info-bg); color: var(--info); }
.badge-active { background-color: var(--success-bg); color: var(--success); }
.badge-rejected { background-color: var(--danger-bg); color: var(--danger); }
.badge-archived { background-color: rgba(100, 116, 139, 0.1); color: var(--text-muted); }

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

th {
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.9rem;
}

td {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

table td:first-child, table th:first-child {
    white-space: nowrap !important;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-ar);
    font-size: 0.95rem;
    transition: var(--transition);
}

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

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

/* Template Builder Specifics */
.builder-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    min-height: 500px;
}

.builder-sidebar {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.field-item {
    padding: 0.75rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    transition: var(--transition);
    user-select: none;
}

.field-item:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: rgba(148, 200, 61, 0.08);
}

.builder-workspace {
    background-color: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 500px;
    position: relative;
}

.builder-workspace.drag-over {
    border-color: var(--primary);
    background-color: rgba(148, 200, 61, 0.05);
}

.workspace-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: var(--text-muted);
    flex-grow: 1;
    text-align: center;
}

.workspace-placeholder i {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Placed Field Card */
.placed-field {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.placed-field:hover {
    border-color: var(--border-hover);
}

.field-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.field-icon {
    width: 36px;
    height: 36px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
}

/* Camera and Sign Pad Modals / Canvas */
.signature-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    height: 200px;
    width: 100%;
    position: relative;
    cursor: crosshair;
}

.signature-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.camera-preview-container {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    background-color: #000;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 4 / 3;
    margin: 0 auto;
}

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

.camera-captured-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

/* Fingerprint UI Simulation */
.fingerprint-scanner {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem auto;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    background-color: rgba(255,255,255,0.02);
}

.fingerprint-scanner i {
    font-size: 3rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.fingerprint-scanner.scanning {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
    animation: pulse 1.5s infinite;
}

.fingerprint-scanner.scanning i {
    color: var(--primary);
}

.fingerprint-scanner.scanned {
    border-color: var(--success);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.fingerprint-scanner.scanned i {
    color: var(--success);
}

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

/* Wizard Progress Bar */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    position: relative;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 3px;
    background-color: var(--border-color);
    z-index: 1;
}

.wizard-progress {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 0%;
    height: 3px;
    background-color: var(--primary);
    z-index: 2;
    transition: var(--transition);
}

.step-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    z-index: 3;
    transition: var(--transition);
    color: var(--text-secondary);
}

.step-indicator.active {
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.step-indicator.completed {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.open .modal-card {
    transform: scale(1);
}

/* Printable Contract layout styling */
.contract-document {
    background-color: white;
    color: #1e293b;
    padding: 3rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    font-family: 'Cairo', sans-serif;
    line-height: 1.8;
}

.contract-header-print {
    text-align: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.contract-body-print {
    margin-bottom: 2.5rem;
}

.contract-footer-print {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    border-top: 2px solid #e2e8f0;
    padding-top: 2rem;
}

.signature-block {
    text-align: center;
}

.signature-img {
    max-height: 100px;
    border-bottom: 1px solid #cbd5e1;
    margin-bottom: 0.5rem;
}

.client-photo-print {
    width: 120px;
    height: 150px;
    object-fit: cover;
    border: 2px solid #cbd5e1;
    border-radius: var(--radius-sm);
}

@media print {
    body {
        background-color: white;
        color: black;
    }
    .app-container, header, .sidebar, .btn, .no-print {
        display: none !important;
    }
    .main-content, .content-wrapper {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    .contract-document {
        box-shadow: none !important;
        padding: 0 !important;
    }
}

/* ============================================================
   COMPATIBILITY ALIASES - For profile.html, users.html, etc.
   ============================================================ */
:root {
    --bg-card: var(--bg-secondary, #131c2e);
    --border: var(--border-color, rgba(255,255,255,0.08));
    --accent-color: #94c83d;
}

/* Shared Layout for profile/users/etc pages */
.layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary, #0b0f19);
    font-family: 'Cairo', sans-serif;
    color: var(--text-primary, #f8fafc);
    position: relative;
}

.layout .sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
}

.layout .sidebar .logo-container {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    padding: 0 0 1rem; border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.layout .sidebar .logo-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: rgba(140,198,63,0.1); display: flex;
    align-items: center; justify-content: center;
}

.layout .sidebar .logo-text {
    font-size: 0.95rem; font-weight: 800; color: var(--text-primary);
}

.layout .sidebar-nav { flex: 1; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }

.layout .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1.1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
}
.layout .nav-item:hover {
    color: var(--text-primary);
    background: rgba(212, 175, 55, 0.06);
    border-color: rgba(212, 175, 55, 0.2);
    transform: translateX(-3px);
}
.layout .nav-item.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(148, 200, 61, 0.15) 0%, rgba(212, 175, 55, 0.1) 100%);
    border: 1px solid rgba(148, 200, 61, 0.35);
    border-right: 4px solid var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(148, 200, 61, 0.15);
}
.layout .nav-item i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.layout .sidebar-footer {
    padding: 16px 16px 8px; border-top: 1px solid var(--border);
}

.layout .user-profile {
    display: flex; align-items: center; gap: 10px;
}

.layout .user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #6fa32e);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 800; color: white; flex-shrink: 0;
}

.layout .main-content {
    flex: 1; padding: 28px 32px; overflow-y: auto;
}

.layout .page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.layout .page-title {
    font-size: 1.4rem; font-weight: 800; color: var(--text-primary);
    display: flex; align-items: center; gap: 10px;
}

/* Shared form styles for new pages */
.form-group { margin-bottom: 0; }
.form-label {
    display: block; font-size: 0.83rem; font-weight: 600;
    color: var(--text-primary, #f8fafc); margin-bottom: 6px;
}
.form-input {
    width: 100%; padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary, #f8fafc);
    font-family: 'Cairo', sans-serif; font-size: 0.9rem;
    transition: all 0.2s; outline: none;
}
.form-input:focus { border-color: var(--accent-color); background: rgba(140,198,63,0.04); box-shadow: 0 0 0 3px rgba(140,198,63,0.1); }
.form-input::placeholder { color: #3a4a5a; }
.form-input option { background: #131c2e; }

/* btn-danger for new pages */
.btn-danger {
    background: rgba(239,68,68,0.1); color: #f87171;
    border: 1px solid rgba(239,68,68,0.3);
    padding: 8px 18px; border-radius: 8px;
    font-family: 'Cairo', sans-serif; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.2s;
}
.btn-danger:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.5); }

/* Custom dynamic rich text styling (Mammoth HTML output) */
.custom-body-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    color: #1e293b;
}
.custom-body-text table td, .custom-body-text table th {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: right;
}
.custom-body-text table th {
    background-color: #f1f5f9;
    font-weight: 700;
}
.custom-body-text p {
    margin-bottom: 1rem;
    color: #1e293b;
}
.custom-body-text ul, .custom-body-text ol {
    margin: 0.5rem 1.5rem 1rem 0;
    padding-right: 1.5rem;
    color: #1e293b;
}
.custom-body-text strong {
    font-weight: 700;
    color: #0f172a;
}

/* ============================================================
   LIGHT THEME (DAY MODE) - HIGH CONTRAST & CRYSTAL CLEAR
   ============================================================ */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
}

[data-theme="light"] body,
[data-theme="light"] .layout {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

[data-theme="light"] header,
[data-theme="light"] .sidebar,
[data-theme="light"] .layout .sidebar {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] .stat-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04) !important;
}

[data-theme="light"] .stat-label {
    color: #475569 !important;
    font-weight: 600 !important;
}

[data-theme="light"] .stat-value {
    color: #0f172a !important;
}

[data-theme="light"] .card,
[data-theme="light"] .modal-box,
[data-theme="light"] .modal-card,
[data-theme="light"] .user-card {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #0f172a !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .nav-link,
[data-theme="light"] .layout .nav-item {
    color: #334155 !important;
}

[data-theme="light"] .nav-link:hover,
[data-theme="light"] .layout .nav-item:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

[data-theme="light"] .nav-link.active,
[data-theme="light"] .layout .nav-item.active {
    background: #f1f8e9 !important;
    color: #2e4d0f !important;
    border-right: 4px solid #94c83d !important;
    font-weight: 800 !important;
}

[data-theme="light"] table th {
    color: #334155 !important;
    background-color: #f8fafc !important;
    border-bottom: 2px solid #cbd5e1 !important;
}

[data-theme="light"] table td {
    color: #0f172a !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] tr:hover td {
    background-color: #f8fafc !important;
}

select option {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 10px;
    font-size: 0.95rem;
}

[data-theme="light"] .form-control,
[data-theme="light"] .form-input,
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="password"],
[data-theme="light"] select {
    background-color: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    color: #0f172a !important;
}

[data-theme="light"] select option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

[data-theme="light"] .form-control::placeholder,
[data-theme="light"] .form-input::placeholder {
    color: #94a3b8 !important;
}

[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-input:focus,
[data-theme="light"] select:focus {
    border-color: #94c83d !important;
    box-shadow: 0 0 0 3px rgba(148, 200, 61, 0.2) !important;
}

/* ================= RESPONSIVE LAYOUT FOR MOBILE, TABLETS AND HALF-SCREEN WIDTHS ================= */
@media (max-width: 992px) {
    .app-container {
        flex-direction: column !important;
    }
    
    .sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        padding: 0.8rem 1rem !important;
        flex-direction: column !important;
        gap: 0.8rem !important;
        border-left: none !important;
        border-bottom: 1px solid var(--border-color) !important;
    }
    
    .logo-container {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .logo-container span {
        display: none !important; /* Hide small subtitle text to save space */
    }
    
    .brand-logo-img {
        height: 42px !important;
    }
    
    .sidebar nav {
        width: 100% !important;
        margin-top: 0 !important;
    }
    
    .nav-list {
        flex-direction: row !important;
        gap: 8px !important;
        overflow-x: auto !important;
        width: 100% !important;
        padding: 4px 0 !important;
        scrollbar-width: none !important; /* Firefox */
        -webkit-overflow-scrolling: touch !important;
    }
    
    .nav-list::-webkit-scrollbar {
        display: none !important; /* Chrome/Safari */
    }
    
    .nav-link {
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
    }
    
    .nav-link.active {
        border-right: 1px solid rgba(148, 200, 61, 0.35) !important;
        border-bottom: 3px solid var(--primary) !important;
    }
    
    .nav-link i {
        font-size: 1rem !important;
        width: auto !important;
    }
    
    .sidebar-footer {
        display: flex !important;
        width: 100% !important;
        border-top: 1px solid var(--border-color) !important;
        padding-top: 0.8rem !important;
        margin-top: 0 !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .sidebar-footer .user-profile {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
    }
    
    .sidebar-footer button {
        width: auto !important;
        margin-top: 0 !important;
        padding: 6px 12px !important;
    }
    
    .content-wrapper {
        padding: 1.2rem 1rem !important;
    }
    
    header {
        padding: 1rem 0 !important;
        height: auto !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        border-bottom: none !important;
    }
    
    .header-actions {
        width: 100% !important;
        justify-content: space-between !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .card {
        padding: 1.2rem !important;
        margin-bottom: 1.2rem !important;
    }
    
    .layout {
        flex-direction: column !important;
    }
    
    .layout .sidebar-nav {
        flex-direction: row !important;
        gap: 8px !important;
        overflow-x: auto !important;
        width: 100% !important;
        padding: 4px 0 !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
        display: flex !important;
    }
    
    .layout .sidebar-nav::-webkit-scrollbar {
        display: none !important;
    }
    
    .layout .nav-item {
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
    }
    
    .layout .nav-item.active {
        border-right: 1px solid rgba(148, 200, 61, 0.35) !important;
        border-bottom: 3px solid var(--primary) !important;
    }
    
    .layout .nav-item i {
        font-size: 1rem !important;
        width: auto !important;
    }
    
    .layout .main-content {
        padding: 1.2rem 1rem !important;
    }
    
    .layout .page-header {
        padding: 1rem 0 !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        border-bottom: none !important;
        width: 100% !important;
    }
    
    .layout .page-header > div {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .template-split {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
}

@media (max-width: 768px) {
    /* Responsive Table to Cards */
    table, thead, tbody, th, td, tr {
        display: block !important;
    }
    thead {
        display: none !important;
    }
    tr {
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-md) !important;
        padding: 1.2rem !important;
        margin-bottom: 1.2rem !important;
        background-color: var(--bg-secondary) !important;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.15) !important;
    }
    td {
        border-bottom: none !important;
        padding: 0.6rem 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        font-size: 0.88rem !important;
        text-align: right !important;
    }
    td::before {
        content: attr(data-label) ": " !important;
        font-weight: 700 !important;
        color: var(--text-secondary) !important;
        margin-left: 10px !important;
    }
    td:last-child {
        margin-top: 0.8rem !important;
        border-top: 1px dashed var(--border-color) !important;
        padding-top: 0.8rem !important;
        justify-content: center !important;
        width: 100% !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .sidebar-footer {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    
    .sidebar-footer button {
        width: 100% !important;
    }

    .signature-container, .biometric-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    .card-header > div {
        width: 100% !important;
        display: flex !important;
        gap: 8px !important;
    }
    
    .card-header .form-control {
        width: 100% !important;
    }

    /* Logs & activity filters */
    .logs-tabs-header {
        flex-direction: column !important;
        gap: 8px !important;
        display: flex !important;
    }
    
    .logs-tabs-header .tab-btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    .logs-filter-row, .backup-banner-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        display: flex !important;
    }
    
    .logs-filter-row > div, .backup-banner-row > div {
        width: 100% !important;
    }
    
    .logs-filter-row button, .backup-banner-row button {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* Collapsed Sidebar Styles */
.sidebar.collapsed {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    padding: 2rem 0.5rem !important;
    align-items: center !important;
    transition: var(--transition);
}

.sidebar.collapsed .logo-container {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem 0 !important;
    width: 100% !important;
    margin-bottom: 0.5rem !important;
}

.sidebar.collapsed .logo-container span {
    display: none !important;
}

.sidebar.collapsed .brand-logo-img {
    height: 36px !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.sidebar.collapsed nav {
    width: 100% !important;
    margin-top: 1rem !important;
}

.sidebar.collapsed .nav-list,
.sidebar.collapsed .sidebar-nav {
    align-items: center !important;
    width: 100% !important;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-item {
    padding: 0.8rem 0 !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: var(--radius-md) !important;
}

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-item span {
    display: none !important;
}

.sidebar.collapsed .nav-link i,
.sidebar.collapsed .nav-item i {
    font-size: 1.4rem !important;
    margin: 0 !important;
    width: auto !important;
}

.sidebar.collapsed .sidebar-footer {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    padding-top: 1rem !important;
}

.sidebar.collapsed .sidebar-footer .user-profile {
    justify-content: center !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    width: auto !important;
}

.sidebar.collapsed .sidebar-footer .user-profile .user-avatar {
    width: 36px !important;
    height: 36px !important;
    margin: 0 !important;
}

.sidebar.collapsed .sidebar-footer .user-profile div,
.sidebar.collapsed .sidebar-footer .user-profile span {
    display: none !important;
}

.sidebar.collapsed .sidebar-footer button.btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    justify-content: center !important;
    margin-top: 10px !important;
    border-radius: 50% !important;
}

.sidebar.collapsed .sidebar-footer button.btn {
    font-size: 0 !important;
}

.sidebar.collapsed .sidebar-footer button.btn i {
    font-size: 1.2rem !important;
}

/* Toggle button styling */
.sidebar-toggle {
    position: absolute;
    right: 266px; /* 280px sidebar width - 14px half-width */
    top: 25px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 1.5px solid var(--border-color);
    color: var(--primary) !important; /* Green primary color for high visibility */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1005;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 0 8px rgba(148, 200, 61, 0.25);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s, border-color 0.3s, color 0.3s, transform 0.2s;
}

.sidebar.collapsed ~ .sidebar-toggle {
    right: 66px; /* 80px sidebar width - 14px half-width */
}

.sidebar-toggle:hover {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(148, 200, 61, 0.45);
}

[data-theme="light"] .sidebar-toggle {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: var(--primary) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 0 6px rgba(148, 200, 61, 0.15) !important;
}

[data-theme="light"] .sidebar-toggle:hover {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(148, 200, 61, 0.3) !important;
}

@media (max-width: 992px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* Notifications Bell & Dropdown Styles */
.notifications-dropdown-container {
    position: relative;
    display: inline-block;
}

.notif-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.notif-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--primary);
    transform: scale(1.05);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: #ef4444; /* bright red */
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-secondary);
}

.notif-dropdown-menu {
    position: absolute;
    top: 48px;
    left: 0; /* Align dropdown to the left in RTL so it doesn't overflow screen */
    width: 320px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 1010;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.notif-dropdown-menu.show {
    display: flex;
}

.notif-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-tertiary);
}

.notif-dropdown-header span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.notif-dropdown-header button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.78rem;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.notif-dropdown-header button:hover {
    text-decoration: underline;
    opacity: 0.9;
}

.notif-dropdown-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: right;
}

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

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

.notif-item.unread {
    background-color: rgba(148, 200, 61, 0.05); /* very light primary glow */
    border-right: 3px solid var(--primary); /* highlight left/right edge based on layout */
}

.notif-icon-box {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-icon-box.pending {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.notif-icon-box.approved {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.notif-icon-box.rejected {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.notif-icon-box.system {
    background-color: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.notif-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.notif-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.2;
}

.notif-desc {
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.4;
    word-break: break-word;
}

.notif-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 4px;
}

/* Live Toast Notification Styles */
.notif-toast {
    position: fixed;
    bottom: 24px;
    left: 24px; /* Bottom left corner is standard and doesn't cover top menus or sidebars */
    width: 320px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-right: 4px solid var(--primary); /* Green brand highlight */
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl; /* Force RTL language layout */
}

.notif-toast.show {
    display: flex;
}

.toast-header {
    padding: 10px 16px;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.toast-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

.toast-close-btn:hover {
    color: var(--text-primary);
}

.toast-body {
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: right;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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