:root {
    --sidebar-width: 290px;
    --header-height: 78px;
    --primary: #3c8dbc;
    --primary-dark: #367fa9;
    --sidebar-bg: #222d32;
    --sidebar-bg-2: #1a2226;
    --sidebar-text: #b8c7ce;
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255,255,255,.08);
    --body-bg: #f4f6f9;
    --card-bg: #ffffff;
    --card-border: #dee6ee;
    --text-main: #2c3e50;
    --text-muted: #76879a;
    --success: #00a65a;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { direction: rtl; }
body {
    margin: 0;
    font-family: 'Tajawal', sans-serif;
    background: var(--body-bg);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    overflow-x: hidden;
}

a { text-decoration: none; }
.table, .form-control, .form-select, .dropdown-menu, .modal-content { direction: rtl; }
.dropdown-menu { text-align: right; }
.form-label { font-weight: 700; color: #4a5c6f; margin-bottom: .45rem; }
.form-control, .form-select {
    min-height: 44px;
    border-radius: .6rem;
    border: 1px solid #cfd8e3;
    background: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: #8eb8d7;
    box-shadow: 0 0 0 .2rem rgba(60,141,188,.14);
}

.payroll-app { min-height: 100vh; }

.app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    overflow-y: auto;
    z-index: 1040;
    border-left: 1px solid #1f2a2f;
    box-shadow: -2px 0 12px rgba(0,0,0,.08);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 16px;
    background: #1a2226;
    border-bottom: 1px solid var(--sidebar-border);
}
.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(60,141,188,.14);
    color: #7cc3ec;
    font-size: 1.25rem;
}
.brand-title { font-size: 1.12rem; font-weight: 800; color: #fff; line-height: 1.2; }
.brand-subtitle { color: #8aa1ad; font-size: .87rem; }

.sidebar-user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 14px 10px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.05);
}
.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(60,141,188,.18);
    color: #9ad2f1;
}
.sidebar-user-label { color: #8ea2ad; font-size: .8rem; }
.sidebar-user-name { color: #fff; font-weight: 700; }

.menu-section {
    padding: 12px 18px 6px;
    color: #6e8794;
    font-size: .78rem;
    font-weight: 800;
}
.sidebar-menu { padding: 0 12px 6px; }
.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--sidebar-text);
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 4px;
    font-weight: 700;
    transition: all .18s ease;
}
.menu-link i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
}
.menu-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.menu-link.active {
    background: var(--primary);
    color: var(--sidebar-text-active);
    box-shadow: inset 3px 0 0 #8fd2f3;
}

.app-main {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
}

.app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.header-right, .header-left { display: flex; align-items: center; gap: 14px; }
.header-title { margin: 0 0 3px; font-size: 1.35rem; font-weight: 800; color: #2f4050; }
.header-subtitle { color: var(--text-muted); font-size: .94rem; }
.header-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: .55rem .85rem;
    border-radius: 999px;
    background: #eef7fc;
    border: 1px solid #dcecf5;
    color: var(--primary-dark);
    font-weight: 700;
}
.menu-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: #fff;
    color: var(--primary-dark);
}

.content-wrapper { padding: 22px; }
.card, .payroll-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: .8rem;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    font-weight: 800;
}
.card-footer {
    background: #fff;
    border-top: 1px solid var(--card-border) !important;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: .85rem;
    padding: 18px;
}
.stat-card span { display: block; color: var(--text-muted); font-weight: 700; margin-bottom: 8px; }
.stat-card strong { color: var(--primary-dark); font-size: 1.8rem; }
.info-box {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: .8rem;
    padding: 15px 16px;
    height: 100%;
}
.info-box span { display: block; color: var(--text-muted); margin-bottom: 6px; }
.info-box strong { color: var(--primary-dark); }

.btn-payroll {
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: .6rem;
    font-weight: 700;
    padding: .7rem 1rem;
}
.btn-payroll:hover, .btn-payroll:focus { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.table thead th {
    background: #f7f9fb;
    color: #596b7c;
    font-weight: 800;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}
.table td, .table th { vertical-align: middle; }
.table-hover tbody tr:hover { background: #fafcfe; }
.table-responsive { overflow-x: auto; }

.pagination-wrap {
    display: flex;
    justify-content: center;
}
.pagination {
    gap: .35rem;
    margin: 0;
    flex-wrap: wrap;
}
.page-link {
    min-width: 40px;
    border-radius: .55rem !important;
    border: 1px solid #d8e0e8;
    color: var(--primary-dark);
    text-align: center;
}
.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}
.page-item.disabled .page-link {
    background: #f2f5f8;
    color: #9aa8b6;
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #ecf2f7, #f8fbfd);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-shell { width: min(100%, 980px); }
.login-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 30px rgba(16,24,40,.08);
}
.login-side {
    background: linear-gradient(135deg, #2c3b41, #3c8dbc);
    color: #fff;
    padding: 42px 34px;
}
.login-form-wrap { padding: 42px 34px; }
.fw-800 { font-weight: 800; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 1039;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(100%);
        transition: transform .22s ease;
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .app-main { margin-right: 0; }
    .app-header { padding: 12px 14px; }
    .header-chip { display: none; }
    .content-wrapper { padding: 14px; }
    .login-panel { grid-template-columns: 1fr; }
}

/* Livewire elegant loader */
.global-livewire-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .22);
    backdrop-filter: blur(4px);
}
.global-livewire-loader.d-none { display: none !important; }
.global-livewire-card {
    min-width: 260px;
    padding: 26px 28px;
    border-radius: 24px;
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(15,118,110,.16);
    box-shadow: 0 24px 70px rgba(15,23,42,.22);
    text-align: center;
}
.global-livewire-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.global-livewire-spinner span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary, #0f766e);
    animation: payroll-loader-bounce .85s infinite ease-in-out;
}
.global-livewire-spinner span:nth-child(2) { animation-delay: .12s; opacity: .8; }
.global-livewire-spinner span:nth-child(3) { animation-delay: .24s; opacity: .65; }
.global-livewire-title {
    font-weight: 800;
    color: #0f766e;
    font-size: 1.05rem;
}
.global-livewire-subtitle {
    color: #64748b;
    font-size: .88rem;
    margin-top: 4px;
}
.livewire-inline-loader {
    position: sticky;
    top: 12px;
    z-index: 30;
    width: fit-content;
    margin: 0 auto 12px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #0f766e;
    font-weight: 800;
    border: 1px solid rgba(15,118,110,.16);
    box-shadow: 0 8px 22px rgba(15,23,42,.08);
}
body.livewire-busy .content-wrapper { cursor: progress; }
body.livewire-busy button[wire\:click],
body.livewire-busy button[wire\:submit] { cursor: wait; }
@keyframes payroll-loader-bounce {
    0%, 80%, 100% { transform: translateY(0) scale(.86); }
    40% { transform: translateY(-8px) scale(1); }
}
