﻿/* ════════════════════════════════════════════
   CSS Custom Properties — موارد Theme Engine
   ════════════════════════════════════════════ */
:root {
    /* Brand colours */
    --mw-primary:           #55BCDB;
    --mw-primary-dark:      #3BA8C7;
    --mw-primary-container: #71457E;
    --mw-primary-cont-dark: #5a3368;
    --mw-secondary:         #71457E;
    --mw-accent:            #55BCDB;

    /* Surfaces – Light */
    --mw-bg:            #f7f9fb;
    --mw-surface:       #ffffff;
    --mw-surface-low:   #f2f4f6;
    --mw-surface-cont:  #eceef0;
    --mw-border:        #cfc3ce;
    --mw-text:          #191c1e;
    --mw-text-muted:    #4d444d;
    --mw-sidebar-bg:    #ffffff;

    /* Fonts */
    --mw-font:            'Cairo', sans-serif;
    --mw-heading-font:    'Cairo', sans-serif;
    --mw-body-font:       'Cairo', sans-serif;
    --mw-font-size:       14px;
    --mw-heading-size:    28px;
    --mw-heading-weight:  700;
    --mw-body-weight:     400;
}

/* ─── Dark Mode ─── */
html.dark {
    --mw-bg:           #111318;
    --mw-surface:      #1d2024;
    --mw-surface-low:  #252930;
    --mw-surface-cont: #2d3139;
    --mw-border:       #3a3f4a;
    --mw-text:         #e2e5ea;
    --mw-text-muted:   #9aa0ab;
    --mw-sidebar-bg:   #1d2024;
}

html.dark body {
    background-color: var(--mw-bg);
    color: var(--mw-text);
}

html.dark .card {
    background-color: var(--mw-surface);
    border-color: var(--mw-border);
    color: var(--mw-text);
}

html.dark .btn-ghost {
    background-color: transparent;
    color: var(--mw-text);
    border-color: var(--mw-border);
}
html.dark .btn-ghost:hover { background-color: var(--mw-surface-low); }

html.dark input,
html.dark select,
html.dark textarea {
    background-color: var(--mw-surface-low);
    color: var(--mw-text);
    border-color: var(--mw-border);
}

html.dark #side-nav,
html.dark [id="sidebar-root"] > * {
    background-color: var(--mw-sidebar-bg) !important;
    border-color: var(--mw-border) !important;
}

html.dark .bg-surface,
html.dark .bg-surface-card {
    background-color: var(--mw-surface) !important;
}

html.dark .bg-surface-container-lowest,
html.dark .bg-surface-container-low,
html.dark .bg-surface-container {
    background-color: var(--mw-surface-low) !important;
}

html.dark .bg-background {
    background-color: var(--mw-bg) !important;
}

html.dark .text-on-surface         { color: var(--mw-text) !important; }
html.dark .text-on-surface-variant { color: var(--mw-text-muted) !important; }
html.dark .border-outline-variant  { border-color: var(--mw-border) !important; }

.mw-hidden-perm {
    display: none !important;
}

html.dark thead tr { background-color: var(--mw-surface-low) !important; }
html.dark tbody tr:hover { background-color: var(--mw-surface-cont) !important; }

/* ─── أساسيات ─── */
body {
    font-family: var(--mw-font);
    color: var(--mw-text);
    background-color: var(--mw-bg);
    font-size: var(--mw-font-size);
}

/* ─── أيقونات Material (لا تورّث خط Cairo) ─── */
.material-symbols-outlined,
.material-symbols-rounded,
.material-icons {
    font-family: 'Material Symbols Outlined' !important;
    font-weight: normal !important;
    font-style: normal !important;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    line-height: 1;
    vertical-align: middle;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

html:not(.mw-icons-ready) .material-symbols-outlined,
html:not(.mw-icons-ready) .material-symbols-rounded,
html:not(.mw-icons-ready) .material-icons,
html:not(.mw-icons-ready) #sidebar-root .material-symbols-outlined,
html:not(.mw-icons-ready) #header-root .material-symbols-outlined,
html:not(.mw-icons-ready) #page-content .material-symbols-outlined,
html:not(.mw-icons-ready) #page-content .material-symbols-rounded {
    font-size: 0 !important;
    line-height: 0 !important;
    overflow: hidden !important;
    color: transparent !important;
    opacity: 0 !important;
    visibility: hidden !important;
    text-indent: -9999px !important;
    min-width: 1.25em;
    min-height: 1.25em;
    speak: never;
}

html.mw-icons-ready .material-symbols-outlined,
html.mw-icons-ready .material-symbols-rounded,
html.mw-icons-ready .material-icons {
    text-indent: 0;
    opacity: 1;
    visibility: visible !important;
}

/* إخفاء نص اسم الأيقونة (palette, settings…) حتى لا يظهر بالإنجليزي */
.material-symbols-outlined,
.material-symbols-rounded {
    overflow: hidden;
    text-overflow: clip;
    max-width: 1.5em;
}

/* هيكل تحميل بدون نص */
.mw-skeleton {
    background: color-mix(in srgb, var(--mw-border, #e5e7eb) 35%, transparent);
    border-radius: 8px;
    min-height: 0.875rem;
}

.mw-skeleton-block {
    min-height: 4rem;
    border-radius: 12px;
}

/* ─── تخطيط الصفحة ─── */
#page-content {
    flex: 1 1 auto;
    min-height: 0;
}

/* ════════════════════════════════════════════
   تخطيط متجاوب — جوال / آيباد / كمبيوتر
   جوال:   < 768px   — قائمة منزلقة + زر ☰
   آيباد:  768–1023px — نفس الجوال (درج فوق المحتوى)
   كمبيوتر: ≥ 1024px  — سايدبار ثابت بجانب المحتوى
   ════════════════════════════════════════════ */

#sidebar-root {
    width: 0;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    z-index: 50;
}

@media (min-width: 1024px) {
    #sidebar-root {
        width: 16rem;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
        background-color: var(--mw-sidebar-bg, #ffffff);
        border-inline-start: 1px solid var(--mw-border, #cfc3ce);
    }

    /* مكان محجوز قبل تحميل الكاش */
    #sidebar-root:empty {
        background-color: var(--mw-sidebar-bg, #ffffff);
    }
}

.mw-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-tap-highlight-color: transparent;
}

.mw-sidebar-backdrop.is-visible {
    display: block;
    opacity: 1;
}

@media (min-width: 1024px) {
    .mw-sidebar-backdrop {
        display: none !important;
        opacity: 0;
    }
}

/* جوال / آيباد: درج منزلق */
#side-nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    height: 100vh;
    width: min(16rem, 88vw);
    max-width: 16rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background-color: var(--mw-sidebar-bg, #ffffff);
    border-inline-start: 1px solid var(--mw-border, #cfc3ce);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(100%);
}

#side-nav.is-open {
    transform: translateX(0);
}

/* كمبيوتر: ثابت داخل التخطيط — بدون فراغ أو تداخل */
@media (min-width: 1024px) {
    #side-nav {
        position: relative;
        top: auto;
        right: auto;
        transform: none !important;
        transition: none;
        box-shadow: none;
        width: 100%;
        max-width: none;
        height: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        flex: 1;
    }

    #side-nav.is-open {
        transform: none !important;
    }
}

/* لا حركة عند التنقل بين الصفحات */
html.mw-layout-ready #side-nav {
    transition: none;
}

#app-main {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

body.sidebar-open {
    overflow: hidden;
}

#menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 1024px) {
    #menu-toggle {
        display: none !important;
    }
}

/* جوال — هوامش أخف */
@media (max-width: 767px) {
    #page-content {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    #app-header {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

}

/* ─── لوحة الإشعارات (RTL + عدم قص النص) ─── */
#app-header {
    overflow: visible;
}

/* صورة/حرف حساب Google في الهيدر */
#header-avatar {
    border-radius: 9999px;
}

.mw-google-avatar-letter {
    font-family: 'Google Sans', 'Roboto', 'Cairo', sans-serif;
    font-size: 1rem;
    line-height: 1;
    letter-spacing: 0;
}

#notif-wrapper {
    position: relative;
    overflow: visible;
}

.mw-notif-panel,
#notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    inset-inline-start: auto;
    width: min(20rem, calc(100vw - 24px));
    max-width: 20rem;
    box-sizing: border-box;
    overflow: hidden;
}

.mw-notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.mw-notif-item-text,
.mw-notif-item-meta {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    max-width: 100%;
}

.mw-notif-item {
    max-width: 100%;
}

@media (max-width: 767px) {
    .mw-notif-panel,
    #notif-panel {
        width: min(20rem, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
    }
}

/* آيباد — مساحة متوسطة */
@media (min-width: 768px) and (max-width: 1023px) {
    #page-content {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #7e747e;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ─── بطاقات ─── */
.card {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 0.75rem;
    border: 1px solid #cfc3ce;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgb(59 129 151 / 0.10);
}

.card-muted {
    background-color: #f2f4f6;
}

/* ─── أزرار ─── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.5;
    background-color: var(--mw-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--mw-primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.5;
    background-color: transparent;
    color: #191c1e;
    border: 1px solid #cfc3ce;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-ghost:hover {
    background-color: #f2f4f6;
    border-color: #7e747e;
}

/* ─── عناوين الصفحات ─── */
.page-header {
    margin-bottom: 32px;
}

.page-header .page-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--mw-primary);
    margin-bottom: 4px;
}

.page-header .page-description {
    font-size: 16px;
    line-height: 1.6;
    color: #4d444d;
}

/* ─── شارات الحالة ─── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
}

.badge-success {
    background-color: rgb(16 185 129 / 0.1);
    color: #10b981;
}

.badge-warning {
    background-color: rgb(245 158 11 / 0.1);
    color: #f59e0b;
}

.badge-info {
    background-color: rgb(85 188 219 / 0.1);
    color: #55bcdb;
}

.badge-error {
    background-color: rgb(239 68 68 / 0.1);
    color: #ef4444;
}

/* ─── جداول ─── */
.data-table {
    overflow: hidden;
    border-radius: 0.75rem;
    border: 1px solid #cfc3ce;
    background-color: #ffffff;
}

.data-table thead {
    background-color: #f2f4f6;
}

.table-row-hover:hover {
    background-color: #eceef0;
    transition: background-color 0.2s ease;
}

/* ─── تأثيرات زجاجية ─── */
.glass-panel {
    background: rgb(255 255 255 / 0.7);
    backdrop-filter: blur(12px);
}

.glass-effect {
    backdrop-filter: blur(8px);
    background: rgb(255 255 255 / 0.15);
}

.glass-card {
    background: rgb(255 255 255 / 0.7);
    backdrop-filter: blur(10px);
}

.bg-gradient-brand {
    background-color: var(--mw-primary);
}

/* ─── بطاقات ملونة ─── */
.card-teal    { border-top: 4px solid #3B8197; }
.card-purple  { border-top: 4px solid #71457E; }
.card-violet  { border-top: 4px solid #965DAF; }
.card-sky     { border-top: 4px solid #55BCDB; }

/* ─── شارة ملونة ─── */
.badge-teal   { background: rgba(59,129,151,0.12);  color: #3B8197; }
.badge-purple { background: rgba(113,69,126,0.12); color: #71457E; }
.badge-violet { background: rgba(150,93,175,0.12); color: #965DAF; }
.badge-sky    { background: rgba(85,188,219,0.12);  color: #55BCDB; }

/* ─── أيقونة ملونة ─── */
.icon-teal    { background: rgba(59,129,151,0.12);  color: #3B8197; }
.icon-purple  { background: rgba(113,69,126,0.12); color: #71457E; }
.icon-violet  { background: rgba(150,93,175,0.12); color: #965DAF; }
.icon-sky     { background: rgba(85,188,219,0.12);  color: #55BCDB; }

/* ─── عناصر تفاعلية ─── */
input[type='range'] {
    accent-color: var(--mw-primary);
}

input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--mw-primary);
    cursor: pointer;
    border-radius: 50%;
}

/* ─── خطوط الصفحة ─── */
h1, h2, h3, .page-title, .text-headline-lg, .text-display-lg, .font-headline-lg, .text-headline-md {
    font-family:   var(--mw-heading-font)   !important;
    font-weight:   var(--mw-heading-weight) !important;
    font-size:     var(--mw-heading-size);
}
body, p, input, button, select, textarea,
.text-body-md, .text-body-lg, .text-label-md, .font-body-md {
    font-family:   var(--mw-body-font)   !important;
    font-weight:   var(--mw-body-weight);
}
/* الأيقونات معرّفة أعلاه — لا تُورّث خط body/button */
button .material-symbols-outlined,
button .material-symbols-rounded,
button .material-icons,
a .material-symbols-outlined,
a .material-symbols-rounded,
a .material-icons {
    font-family: 'Material Symbols Outlined' !important;
}


.active-ring {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--mw-primary);
}

.circular-progress {
    position: relative;
    background: conic-gradient(var(--progress-color) calc(var(--value) * 1%), #e2e8f0 0);
    border-radius: 50%;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circular-progress::before {
    content: '';
    background-color: #ffffff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    position: absolute;
}

.shimmer {
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.1), transparent);
    background-size: 200% 100%;
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ─── الشريط الجانبي ─── */
#side-nav .nav-link.active {
    color: var(--mw-primary);
    font-weight: 700;
    border-inline-end-width: 3px;
    border-inline-end-style: solid;
    border-color: var(--mw-primary);
    background-color: color-mix(in srgb, var(--mw-primary) 10%, transparent);
}

.dark #side-nav .nav-link.active {
    color: #e9b4f6;
}

#side-nav .nav-link.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
