: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);
}

.hr-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: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    overflow: hidden;
}
.brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}
.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;
}
.menu-group {
    padding: 0 10px;
    margin-top: 6px;
}
.menu-group-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    color: #d4e1e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 800;
}
.menu-group-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.menu-group-toggle:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.menu-group-toggle .bi-chevron-down {
    transition: transform .2s ease;
    font-size: .85rem;
}
.menu-group-toggle.collapsed .bi-chevron-down {
    transform: rotate(-90deg);
}
.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; }
.mobile-university-logo {
    display: none;
    width: 122px;
    height: auto;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.12));
}
.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);
}

.user-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dce7f1;
    background: #fff;
    color: #2f4050;
    border-radius: 999px;
    padding: .35rem .7rem;
    font-weight: 700;
}
.user-menu-toggle:hover,
.user-menu-toggle:focus {
    background: #f6fbff;
    border-color: #cfe2f2;
}
.header-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #d7e3ee;
}
.header-user-avatar-lg {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #d7e3ee;
}
.user-menu-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.content-wrapper { padding: 22px; }
.card, .hr-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;
}
.quality-kpi {
    border: 1px solid var(--card-border);
    border-radius: .85rem;
    padding: 14px;
    background: #fff;
    height: 100%;
}
.quality-kpi-label {
    color: #3f5468;
    font-size: .9rem;
    margin-bottom: 6px;
    font-weight: 700;
}
.quality-kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
}
.quality-kpi-danger {
    background: #fff1f1;
    border-color: #f4cdcd;
}
.quality-kpi-danger .quality-kpi-value { color: #c0392b; }
.quality-kpi-warning {
    background: #fff7ed;
    border-color: #f6dec0;
}
.quality-kpi-warning .quality-kpi-value { color: #c06f13; }
.quality-kpi-rose {
    background: #fff5f7;
    border-color: #f2d3db;
}
.quality-kpi-rose .quality-kpi-value { color: #be4b6c; }
.quality-kpi-violet {
    background: #f7f5ff;
    border-color: #ddd4fd;
}
.quality-kpi-violet .quality-kpi-value { color: #6d4fc2; }
.quality-kpi-slate {
    background: #f5f8fb;
    border-color: #d8e2ea;
}
.quality-kpi-slate .quality-kpi-value { color: #476175; }
.quality-kpi-info {
    background: #edf8ff;
    border-color: #cde8f7;
}
.quality-kpi-info .quality-kpi-value { color: #237da5; }
.quality-progress-box {
    padding: 12px;
    border: 1px solid #e1e8ef;
    border-radius: .75rem;
    background: #fbfdff;
}
.quality-progress-box .progress {
    height: 10px;
    border-radius: 999px;
    background: #e9f0f7;
}
.executive-hero {
    border: 1px solid #d9e5ef;
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff, #f7fbff);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.executive-hero-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #29435a;
}
.executive-hero-subtitle {
    color: #6d8295;
    font-size: .93rem;
}
.executive-score {
    min-width: 132px;
    text-align: center;
    border-radius: 12px;
    padding: 10px;
    background: #eaf4fb;
    border: 1px solid #cfe2f2;
}
.executive-score span {
    display: block;
    color: #567087;
    font-size: .82rem;
}
.executive-score strong {
    font-size: 1.55rem;
    color: #1f5f8f;
}
.quick-issue-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.quick-filter-btn {
    border: 1px solid #d4e2ee;
    border-radius: 999px;
    padding: .35rem .75rem;
    color: #49637a;
    background: #f8fbfe;
    font-weight: 700;
    font-size: .86rem;
}
.quick-filter-btn:hover {
    border-color: #bdd6ea;
    background: #eef6fd;
    color: #2f587a;
}
.quick-filter-btn.active {
    border-color: #3c8dbc;
    background: #3c8dbc;
    color: #fff;
}
.top-issues-list {
    display: grid;
    gap: 10px;
}
.top-issue-item {
    border: 1px solid #e2e9f0;
    border-radius: .7rem;
    padding: 10px 12px;
    background: #fcfdff;
}
.chart-panel {
    min-height: 280px;
    position: relative;
}
.chart-placeholder {
    min-height: 220px;
    border: 1px dashed #d6e2ec;
    border-radius: 12px;
    background: #f9fcff;
    color: #6e8598;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    font-weight: 700;
}
.dashboard-top-card .card-body {
    min-height: 122px;
}

.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-hr {
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: .6rem;
    font-weight: 700;
    padding: .7rem 1rem;
}
.btn-hr:hover, .btn-hr: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:
        radial-gradient(circle at 20% 15%, rgba(93, 173, 226, .18), transparent 35%),
        radial-gradient(circle at 85% 90%, rgba(26, 188, 156, .16), transparent 30%),
        linear-gradient(135deg, #eef4f9, #f8fbff);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}
.login-shell { width: min(100%, 1080px); }
.login-panel {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: #fff;
    border-radius: 1.2rem;
    overflow: hidden;
    border: 1px solid var(--card-border);
    box-shadow: 0 20px 45px rgba(16, 24, 40, .14);
    animation: login-panel-in .55s ease-out;
}
.login-side {
    background: linear-gradient(140deg, #12344a, #20698f 50%, #2f89b6);
    color: #fff;
    padding: 38px 34px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.login-side::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, rgba(255,255,255,.06), transparent 45%);
    pointer-events: none;
}
.login-side::after {
    content: "";
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.2), rgba(255,255,255,0));
    top: -110px;
    left: -80px;
    pointer-events: none;
}
.login-form-wrap {
    padding: 48px 38px;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}
.fw-800 { font-weight: 800; }
.brand-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.brand-logo {
    width: clamp(170px, 26vw, 250px);
    max-width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,.22));
    animation: logo-float 3.6s ease-in-out infinite;
}
.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .45rem .85rem;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.22);
    font-weight: 700;
    font-size: .95rem;
}
.login-error-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    padding: .8rem .95rem;
    border-radius: .75rem;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #b4232a;
    font-weight: 700;
}
.password-field-wrap {
    position: relative;
}
.password-field-wrap .form-control {
    padding-left: 54px;
}
.password-toggle {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: #e8eef6;
    color: #32526c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.password-toggle:hover {
    background: #dce7f2;
}
.login-submit-btn {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.btn-loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
.login-submit-btn.is-loading .btn-loader {
    display: inline-block !important;
}
.login-submit-btn.is-loading {
    opacity: .88;
    cursor: wait;
}
.login-submit-btn.is-loading .btn-label {
    opacity: .95;
}
.login-side h1 {
    font-size: clamp(1.8rem, 2.2vw, 2.65rem);
    font-weight: 800;
    line-height: 1.2;
}
.login-side-points {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: .65rem;
    color: rgba(255,255,255,.9);
    font-weight: 500;
    width: min(100%, 420px);
    text-align: right;
}
.login-side-points li {
    position: relative;
    padding-right: 1.3rem;
}
.login-side-points li::before {
    content: "";
    width: .52rem;
    height: .52rem;
    border-radius: 50%;
    background: #a3ddff;
    position: absolute;
    right: 0;
    top: .48rem;
}
.login-form-wrap .form-control {
    border-radius: .85rem;
    min-height: 52px;
    background: #f9fbfe;
}
.login-form-wrap .btn-hr {
    min-height: 54px;
    border-radius: .85rem;
    font-size: 1.35rem;
    letter-spacing: .2px;
}

.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; }
    .user-menu-name { max-width: 95px; }
    .content-wrapper { padding: 14px; }
    .login-page {
        overflow-y: auto;
        align-items: center;
        padding: 14px;
    }
    .login-panel {
        grid-template-columns: 1fr;
        width: min(100%, 640px);
        margin-inline: auto;
    }
    .login-form-wrap {
        padding: 24px 20px;
    }
    .login-side {
        display: flex;
    }
    .brand-logo {
        width: clamp(130px, 40vw, 190px);
    }
    .login-side h1 {
        font-size: clamp(1.6rem, 7vw, 2rem);
        margin-bottom: .6rem !important;
    }
    .login-side p {
        margin-bottom: .8rem !important;
    }
    .login-side-points {
        gap: .4rem;
        font-size: .95rem;
    }
}

@media (max-width: 767.98px) {
    .executive-hero {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .header-title,
    .header-subtitle {
        display: none;
    }
    .mobile-university-logo {
        display: block;
        width: 96px;
    }
    .app-header {
        height: auto;
        min-height: 72px;
        padding: 10px 12px;
    }
    .dashboard-top-card .card-body {
        min-height: 96px;
    }
    .user-menu-toggle {
        padding: .3rem .45rem;
    }
}

@media (max-width: 767.98px) {
    .login-panel {
        width: min(100%, 560px);
    }
    .login-side {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .login-page {
        padding: 10px;
    }
    .login-panel {
        border-radius: .95rem;
    }
    .login-side, .login-form-wrap {
        padding: 18px 14px;
    }
    .brand-logo {
        width: clamp(118px, 44vw, 168px);
    }
    .brand-badge {
        font-size: .85rem;
        padding: .35rem .7rem;
    }
    .login-side-points {
        display: none;
    }
    .login-form-wrap .btn-hr {
        min-height: 50px;
        font-size: 1.15rem;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes login-panel-in {
    from { opacity: 0; transform: translateY(16px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes logo-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 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: hr-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 hr-loader-bounce {
    0%, 80%, 100% { transform: translateY(0) scale(.86); }
    40% { transform: translateY(-8px) scale(1); }
}
