/* =========================================================================
   Employee Settlements 360 - Ultra-Clean Premium Design System
   High-End SaaS Aesthetics & Flawless Responsive Alignment
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
    --font-cairo: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
    --font-body: 'IBM Plex Sans Arabic', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Light Theme Palette */
    --bg-window: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-surface-alt: #F1F5F9;
    --bg-sidebar: #0F172A;
    --sidebar-btn-hover: #1E293B;
    --sidebar-btn-active: #2563EB;
    
    --border-color: #E2E8F0;
    --border-input: #CBD5E1;
    --border-subtle: #F1F5F9;
    
    --text-main: #0F172A;
    --text-muted: #64748B;
    --text-sidebar: #94A3B8;
    --text-navy: #1E3A8A;
    
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    
    --teal-val: #0D9488;
    --teal-bg: #F0FDFA;
    --teal-border: #A7F3D0;
    
    --red-val: #DC2626;
    --red-bg: #FEF2F2;
    --red-border: #FECACA;
    
    --amber-val: #D97706;
    --amber-bg: #FFFBEB;
    
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
    --bg-window: #0B0F17;
    --bg-surface: #131B2E;
    --bg-surface-alt: #0E1524;
    --bg-sidebar: #090D16;
    --sidebar-btn-hover: #172238;
    --sidebar-btn-active: #2563EB;
    
    --border-color: #1E293B;
    --border-input: #293548;
    --border-subtle: #141D30;
    
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-sidebar: #94A3B8;
    --text-navy: #38BDF8;
    
    --primary: #3B82F6;
    --primary-hover: #60A5FA;
    --primary-light: rgba(59, 130, 246, 0.15);
    
    --teal-val: #14B8A6;
    --teal-bg: rgba(20, 184, 166, 0.12);
    --teal-border: rgba(20, 184, 166, 0.3);
    
    --red-val: #EF4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --red-border: rgba(239, 68, 68, 0.3);
    
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --card-shadow-hover: 0 12px 24px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-window);
    color: var(--text-main);
    direction: rtl;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================================================================
   1. Auth & Login Screen (Centered & Premium Glassmorphism)
   ========================================================================= */
.auth-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e3a8a 0%, #0f172a 60%, #020617 100%);
    padding: 24px;
    z-index: 9999;
    overflow-y: auto;
}

.auth-card {
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 440px;
    padding: 40px 32px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: auto;
    animation: authFadeIn 0.3s ease-out;
}

[data-theme="dark"] .auth-card {
    background: #131b2e;
    border-color: #23304d;
    color: #f1f5f9;
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(15px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #ffffff;
    margin: 0 auto 14px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.auth-header h2 {
    font-family: var(--font-cairo);
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.auth-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-tabs {
    display: flex;
    background: var(--bg-surface-alt);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 22px;
    gap: 4px;
    border: 1px solid var(--border-color);
}

.auth-tab-btn {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.auth-tab-btn:hover {
    color: var(--text-main);
}

.auth-tab-btn.active {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-demo-badge {
    background: #eff6ff;
    border: 1px dashed #bfdbfe;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: #1e40af;
    line-height: 1.6;
    margin-top: 6px;
}

[data-theme="dark"] .auth-demo-badge {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.input-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-icon-wrap i {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    font-size: 1.2rem;
    pointer-events: none;
}

.input-icon-wrap .qline-edit {
    padding-right: 42px;
    width: 100%;
}

.toggle-pwd-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    z-index: 10;
}

/* =========================================================================
   2. Main Layout & Sidebar
   ========================================================================= */
.desktop-window {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Mobile Navbar */
.mobile-navbar {
    display: none;
    height: 60px;
    background-color: var(--bg-sidebar);
    color: #FFFFFF;
    padding: 0 18px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-brand {
    font-family: var(--font-cairo);
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-toggle-btn {
    background: transparent;
    border: none;
    color: #FFFFFF;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    z-index: 90;
    backdrop-filter: blur(3px);
}

.sidebar-backdrop.show {
    display: block;
}

/* Sidebar Styling */
.sidebar-frame {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    user-select: none;
    z-index: 95;
    position: sticky;
    top: 0;
    height: 100vh;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-title {
    color: #FFFFFF;
    font-family: var(--font-cairo);
    font-size: 16px;
    font-weight: 800;
    padding: 24px 20px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    line-height: 1.4;
    letter-spacing: -0.2px;
}

.sidebar-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 14px;
    flex-grow: 1;
    overflow-y: auto;
    scrollbar-width: none; /* Hide default ugly scrollbars */
}

.sidebar-buttons::-webkit-scrollbar {
    display: none;
}

.sidebar-btn {
    background-color: transparent;
    color: var(--text-sidebar);
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    text-align: right;
    font-size: 10.5pt;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.sidebar-btn:hover {
    background-color: var(--sidebar-btn-hover);
    color: #FFFFFF;
}

.sidebar-btn.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-btn i {
    font-size: 1.3rem;
}

/* User Session Profile Box */
.sidebar-user-box {
    padding: 12px 14px;
    margin: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 9pt;
    font-weight: 700;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 8pt;
    color: #94A3B8;
}

.btn-logout {
    background: transparent;
    border: none;
    color: #EF4444;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.sidebar-version {
    color: #A7F3D0;
    font-size: 8.5pt;
    font-weight: 700;
}

/* =========================================================================
   3. Content Stack & Screens
   ========================================================================= */
.content-stack {
    flex-grow: 1;
    background-color: var(--bg-window);
    position: relative;
    padding: 32px 36px;
    min-width: 0;
    overflow-y: auto;
}

.screen-pane {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
}

.screen-pane.active {
    display: block;
    animation: screenFade 0.25s ease-out;
}

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

.screen-header {
    font-family: var(--font-cairo);
    color: var(--text-main);
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.section-header {
    font-family: var(--font-cairo);
    color: var(--text-navy);
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 18px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Cards */
.card-frame {
    background-color: var(--bg-surface);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease;
}

.card-frame:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.card-value {
    color: var(--teal-val);
    font-size: 1.8rem;
    font-weight: 800;
    font-family: var(--font-mono);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

/* Tab Widget */
.qtab-widget {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background-color: var(--bg-surface);
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.qtab-bar {
    display: flex;
    background-color: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px 0;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
}

.qtab-button {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    padding: 12px 22px;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.qtab-button:hover {
    color: var(--text-main);
}

.qtab-button.active {
    background: var(--bg-surface);
    color: var(--primary);
    border-color: var(--border-color);
    border-bottom: 2px solid var(--bg-surface);
    margin-bottom: -1px;
}

.qtab-body {
    padding: 28px;
}

.qtab-pane {
    display: none;
}

.qtab-pane.active {
    display: block;
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

.qline-edit, .qcombo-box, .qdate-edit, .qspin-box {
    border: 1px solid var(--border-input);
    border-radius: 10px;
    padding: 11px 16px;
    background-color: var(--bg-surface);
    font-size: 0.95rem;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
    transition: border 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.qline-edit:focus, .qcombo-box:focus, .qdate-edit:focus, .qspin-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.duration-display {
    color: #1E40AF;
    background-color: #EFF6FF;
    font-weight: 700;
    font-size: 1rem;
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid #BFDBFE;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

[data-theme="dark"] .duration-display {
    color: #93C5FD;
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.tafqeet-box {
    color: #1E40AF;
    border: 1px dashed #3B82F6;
    background-color: #EFF6FF;
    padding: 14px 18px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 16px;
}

[data-theme="dark"] .tafqeet-box {
    color: #93C5FD;
    background-color: rgba(59, 130, 246, 0.15);
    border-color: #3B82F6;
}

/* Settlement Screen Layout */
.settlement-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 28px;
    align-items: start;
}

.summary-panel {
    background-color: var(--bg-surface);
    border-radius: 16px;
    border: 1px solid var(--teal-border);
    padding: 24px;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 24px;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-subtle);
}

.summary-row.total-gross {
    font-weight: 800;
    color: var(--teal-val);
    border-bottom: 2px solid var(--border-color);
}

.summary-row.total-deduct {
    font-weight: 800;
    color: var(--red-val);
    border-bottom: 2px solid var(--border-color);
}

.net-amount-card {
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: #FFFFFF;
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    margin: 18px 0;
    box-shadow: 0 10px 20px rgba(13, 148, 136, 0.3);
}

.net-amount-card.negative {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.3);
}

.net-amount-card .title {
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0.95;
}

.net-amount-card .amount {
    font-size: 2.2rem;
    font-weight: 900;
    font-family: var(--font-mono);
    margin: 6px 0;
    line-height: 1.1;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-input);
    border-radius: 10px;
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-danger {
    background-color: #DC2626;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger:hover {
    background-color: #B91C1C;
}

/* Table Widget */
.qtable-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow-x: auto;
    margin-top: 14px;
}

.qtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    text-align: right;
    min-width: 650px;
}

.qtable th {
    background-color: var(--bg-surface-alt);
    color: var(--text-muted);
    font-weight: 800;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.qtable td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    white-space: nowrap;
}

.qtable tr:hover {
    background-color: var(--primary-light);
}

/* Developer Card (About Screen) */
.dev-card {
    background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
    border: 2px solid #10B981;
    border-radius: 14px;
    padding: 24px;
    color: #064E3B;
    margin-top: 24px;
}

[data-theme="dark"] .dev-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 78, 59, 0.3));
    color: #A7F3D0;
    border-color: #059669;
}

.dev-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #047857;
    margin-bottom: 8px;
}

[data-theme="dark"] .dev-title {
    color: #34D399;
}

/* Modal Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 20px;
}

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

.modal-dialog {
    background: var(--bg-surface);
    border-radius: 16px;
    border: 2px solid var(--primary);
    width: 100%;
    max-width: 650px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    background: var(--bg-surface-alt);
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 800;
    font-size: 1.1rem;
}

.modal-body {
    padding: 24px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 22px;
    background: var(--bg-surface-alt);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast */
.toast-msg {
    position: fixed;
    bottom: 28px;
    left: 28px;
    background: #0F172A;
    color: #FFFFFF;
    padding: 14px 22px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.35);
    z-index: 20000;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* =========================================================================
   4. Responsive Breakpoints
   ========================================================================= */
@media (max-width: 1100px) {
    .settlement-layout {
        grid-template-columns: 1fr;
    }
    .summary-panel {
        position: relative;
        top: 0;
    }
}

@media (max-width: 900px) {
    .desktop-window {
        flex-direction: column;
    }
    .mobile-navbar {
        display: flex;
    }
    .sidebar-frame {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 270px;
        transform: translateX(100%);
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
    }
    .sidebar-frame.open {
        transform: translateX(0);
    }
    .content-stack {
        padding: 20px 16px;
    }
    .screen-header {
        font-size: 1.2rem;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 550px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .content-stack {
        padding: 16px 12px;
    }
    .screen-header button {
        width: 100%;
    }
}
