/* ==========================================================
   نظام الفواتير الإلكترونية — التنسيقات الأساسية (RTL)
   ========================================================== */

:root {
    --brand:        #0f766e;
    --brand-dark:   #115e59;
    --brand-light:  #ccfbf1;
    --sidebar-bg:   #0f172a;
    --sidebar-text: #cbd5e1;
    --body-bg:      #f1f5f9;
    --sidebar-w:      260px;
    --sidebar-w-mini: 74px;
}

* { font-family: 'Rubik', 'Segoe UI', Tahoma, sans-serif; }

body {
    background: var(--body-bg);
    color: #1e293b;
}

/* ---------- الهيكل ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; right: 0; bottom: 0;
    overflow-y: auto;
    transition: width .2s ease;
    z-index: 1030;
}

.app-main {
    margin-right: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    transition: margin-right .2s ease;
    display: flex;
    flex-direction: column;
}

.app-shell.collapsed .app-sidebar { width: var(--sidebar-w-mini); }
.app-shell.collapsed .app-main    { margin-right: var(--sidebar-w-mini); }
.app-shell.collapsed .brand-text,
.app-shell.collapsed .nav-link-item span,
.app-shell.collapsed .sidebar-divider { display: none; }
.app-shell.collapsed .nav-link-item { justify-content: center; }

.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1rem;
    font-size: 1.05rem; font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { font-size: 1.4rem; color: var(--brand-light); }

.sidebar-nav { padding: .75rem .5rem; }

.nav-link-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .8rem;
    margin-bottom: .2rem;
    border-radius: .5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .93rem;
    transition: background .15s, color .15s;
}
.nav-link-item:hover  { background: rgba(255,255,255,.07); color: #fff; }
.nav-link-item.active { background: var(--brand); color: #fff; }
.nav-link-item.disabled { opacity: .45; pointer-events: none; }
.nav-link-item i { font-size: 1.05rem; }

.sidebar-divider {
    padding: .9rem .8rem .35rem;
    font-size: .72rem;
    letter-spacing: .02em;
    color: #64748b;
    text-transform: none;
}

/* ---------- الشريط العلوي ---------- */
.app-topbar {
    position: sticky;          /* ملاحظة: لا تضع overflow-x:hidden على أي حاوٍ أعلى */
    top: 0;
    z-index: 1020;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: .6rem 1rem;
    display: flex; align-items: center; gap: 1rem;
}
.topbar-title   { font-weight: 600; font-size: 1rem; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .6rem; }
.user-chip {
    font-size: .85rem; color: #475569;
    display: inline-flex; align-items: center; gap: .35rem;
}
.btn-toggle { background: #f1f5f9; border: 1px solid #e2e8f0; }

.app-content { padding: 1.25rem; flex: 1; }
.app-footer  { padding: .8rem 1.25rem; font-size: .8rem; color: #64748b; text-align: center; }

/* ---------- البطاقات ---------- */
.panel { border: none; box-shadow: 0 1px 3px rgba(15,23,42,.08); border-radius: .7rem; }
.panel .card-header { background: #fff; border-bottom: 1px solid #eef2f7; font-weight: 600; border-radius: .7rem .7rem 0 0; }

.stat-card {
    background: #fff;
    border-radius: .7rem;
    padding: 1rem;
    display: flex; align-items: center; gap: .9rem;
    box-shadow: 0 1px 3px rgba(15,23,42,.08);
    height: 100%;
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: .6rem;
    display: grid; place-items: center;
    font-size: 1.3rem; color: #fff;
    flex: 0 0 auto;
}
.stat-primary .stat-icon { background: var(--brand); }
.stat-success .stat-icon { background: #16a34a; }
.stat-warning .stat-icon { background: #d97706; }
.stat-danger  .stat-icon { background: #dc2626; }

.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .82rem; color: #64748b; }

.summary-number { font-size: 1.6rem; font-weight: 700; color: var(--brand-dark); }
.summary-label  { font-size: .85rem; color: #64748b; }

/* ---------- صفحة الدخول ---------- */
.login-page {
    min-height: 100vh;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #0f766e 100%);
    padding: 1rem;
}
.login-card {
    background: #fff;
    width: 100%; max-width: 400px;
    padding: 2rem;
    border-radius: .9rem;
    box-shadow: 0 12px 30px rgba(0,0,0,.25);
}
.login-head { text-align: center; margin-bottom: 1.5rem; }
.login-head i  { font-size: 2.4rem; color: var(--brand); }
.login-head h1 { font-size: 1.15rem; font-weight: 600; margin: .5rem 0 .25rem; }
.login-head p  { font-size: .8rem; color: #64748b; margin: 0; }

/* ---------- الجوال ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { width: var(--sidebar-w); transform: translateX(100%); }
    .app-main    { margin-right: 0; }
    .app-shell.mobile-open .app-sidebar { transform: translateX(0); }
    .app-shell.collapsed .app-sidebar   { width: var(--sidebar-w); }
    .app-shell.collapsed .app-main      { margin-right: 0; }
    .app-shell.collapsed .brand-text,
    .app-shell.collapsed .nav-link-item span,
    .app-shell.collapsed .sidebar-divider { display: inline; }
}

/* ---------- المخططات ---------- */
/* الارتفاع ثابت هنا و maintainAspectRatio معطّل في الرسم،
   وإلا حسب كلٌّ منهما حجمه من الآخر فاهتز بلا توقف. */
.chart-box {
    position: relative;
    width: 100%;
    height: 320px;
}

.chart-box canvas {
    position: absolute;
    inset: 0;
}

@media (max-width: 767.98px) {
    .chart-box { height: 240px; }
}

/* ---------- حقوق التطوير ---------- */
.credit a {
    color: #64748b;
    text-decoration: none;
    font-size: .8rem;
    transition: color .15s;
}
.credit a:hover { color: var(--brand); }
.credit i { margin-inline-end: .25rem; }

.login-card .credit a { color: #94a3b8; }
.login-card .credit a:hover { color: var(--brand); }
