/* ==========================================================================
   home-redesign.css — تنسيق الصفحة الرئيسية + القائمة الجانبية الجديدة.

   قواعد هذا الملف:
   - كل الكلاسات تبدأ بـ gh- فلا تتعارض مع portal.css (الصفحات القديمة تفضل شغالة).
   - الألوان كلها متغيرات في :root تحت، غيّر لون واحد يتغير الموقع كله.
   - الاتجاه RTL: استخدمنا Logical Properties (inline-start/end) لتفادي قلب الاتجاهات يدويًا.
   - ضيف الملف في App.razor بعد portal.css:
       <link rel="stylesheet" href="css/home-redesign.css" />
   ========================================================================== */

:root {
    /* ألوان الهوية (مأخوذة من شعار غصون: أخضر + ليموني + برتقالي) */
    --gh-green-900: #0d4636;
    --gh-green-700: #14664d;
    --gh-green-600: #1d8363;
    --gh-green-100: #dff1e8;
    --gh-green-50:  #f0f8f4;
    --gh-lime:      #8cc63f;
    --gh-orange:    #e9a23b;
    --gh-red:       #d36d57;

    /* الأسطح والنصوص */
    --gh-bg:      #f3f6f4;   /* خلفية الصفحة: رمادي مخضر هادئ */
    --gh-surface: #ffffff;
    --gh-border:  #e4eae6;
    --gh-text:    #17322a;
    --gh-muted:   #6a7e76;

    /* أنصاف الأقطار: الكروت الكبيرة أنعم من الأزرار والحقول عمدًا (تدرّج بصري) */
    --gh-r-card: 18px;
    --gh-r-ctrl: 12px;

    --gh-sidebar-w: 272px;
}

/* ───────────── الهيكل العام ───────────── */
.gh-shell {
    direction: rtl;
    display: grid;
    grid-template-columns: var(--gh-sidebar-w) minmax(0, 1fr); /* العمود الأول = اليمين في RTL */
    min-height: 100vh;
    background: var(--gh-bg);
    color: var(--gh-text);
    font-family: inherit;
}
.gh-shell *, .gh-shell *::before, .gh-shell *::after { box-sizing: border-box; }
.gh-shell .ico { width: 20px; height: 20px; flex: none; }
.gh-shell h1, .gh-shell h2, .gh-shell h3, .gh-shell p { margin: 0; }

/* ظهور حلقة التركيز عند التنقل بالكيبورد (إتاحة الوصول) */
.gh-shell :focus-visible { outline: 3px solid var(--gh-lime); outline-offset: 2px; }

.gh-main { min-width: 0; padding: 26px 34px 34px; }

/* ==========================================================================
   القائمة الجانبية
   ========================================================================== */
.gh-sidebar {
    position: sticky; top: 0;
    height: 100vh;
    display: flex; flex-direction: column;
    background: var(--gh-surface);
    border-inline-end: 1px solid var(--gh-border); /* الحد على جهة المحتوى */
    z-index: 60;
}

/* الشعار */
.gh-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px 18px;
}
.gh-brand img { width: 48px; height: 48px; object-fit: contain; flex: none; }
.gh-brand strong { display: block; font-size: 16px; font-weight: 800; color: var(--gh-green-900); line-height: 1.3; }
.gh-brand small { display: block; font-size: 12px; color: var(--gh-muted); margin-top: 2px; }

/* منطقة البنود (بتعمل Scroll لوحدها لو القائمة طويلة) */
.gh-nav {
    flex: 1; min-height: 0;
    overflow-y: auto;
    padding: 4px 14px 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--gh-border) transparent;
}
.gh-nav-label {
    padding: 18px 12px 6px;
    font-size: 12px; font-weight: 700;
    color: var(--gh-muted);
}

/* البند الأساسي — حجم خط وارتفاع موحدين لكل البنود (كانت المشكلة القديمة اختلاف الأحجام) */
.gh-nav-link {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 11px 12px;
    margin: 2px 0;
    border: 0; border-radius: var(--gh-r-ctrl);
    background: transparent;
    color: #3b574d;
    font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.4;
    text-align: start; text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.gh-nav-link:hover { background: var(--gh-green-50); color: var(--gh-green-700); }
.gh-nav-link.active { background: var(--gh-green-100); color: var(--gh-green-700); font-weight: 800; }
/* شريط ليموني على حافة القائمة يوضح البند النشط */
.gh-nav-link.active::before {
    content: ""; position: absolute;
    inset-inline-start: -14px; top: 9px; bottom: 9px; width: 4px;
    border-radius: 4px; background: var(--gh-lime);
}
/* المجموعة اللي بداخلها صفحة نشطة: نلون النص بدون خلفية */
.gh-nav-group.has-active { color: var(--gh-green-700); font-weight: 800; }

/* السهم: مربع بحدين مدوّر 45° — بنقلبه لما تفتح المجموعة */
.gh-chevron {
    margin-inline-start: auto;
    width: 8px; height: 8px;
    border: solid currentColor; border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .2s ease;
    opacity: .6;
}
.gh-nav-group.is-open .gh-chevron { transform: rotate(-135deg) translateY(-2px); }

/* القائمة الفرعية: فتح/قفل ناعم بدون JavaScript بخدعة grid-template-rows */
.gh-sub {
    display: grid; grid-template-rows: 0fr;
    transition: grid-template-rows .25s ease;
}
.gh-sub.open { grid-template-rows: 1fr; }
.gh-sub > div { min-height: 0; overflow: hidden; }
/* المجموعة المقفولة تتخفى عن الكيبورد وقارئات الشاشة */
.gh-sub:not(.open) > div { visibility: hidden; }

.gh-sub-list {
    list-style: none;
    margin: 2px 22px 6px 0; /* مسافة من اليمين ليظهر خط الشجرة تحت أيقونة الأب */
    padding: 0 14px 0 0;
    border-inline-start: 2px solid var(--gh-border);
}
.gh-sub-link {
    display: block;
    padding: 8px 12px; margin: 1px 0;
    border-radius: 10px;
    color: #55695f; font-size: 13.5px; font-weight: 500; text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.gh-sub-link:hover { background: var(--gh-green-50); color: var(--gh-green-700); }
.gh-sub-link.active { background: var(--gh-green-50); color: var(--gh-green-700); font-weight: 800; }

/* تذييل القائمة: بطاقة المستخدم + تسجيل الخروج */
.gh-sidebar-footer { padding: 12px 14px 16px; border-top: 1px solid var(--gh-border); }
.gh-user { display: flex; align-items: center; gap: 11px; padding: 8px 6px 12px; }
.gh-avatar {
    width: 40px; height: 40px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--gh-green-700); color: #fff;
    font-weight: 800; font-size: 16px;
}
.gh-user-info { min-width: 0; }
.gh-user-info strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gh-user-info small { display: block; font-size: 12px; color: var(--gh-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gh-logout {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--gh-border); border-radius: var(--gh-r-ctrl);
    background: #fff; color: #8a4a3d;
    font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.gh-logout:hover { background: #fdf1ee; border-color: #f0c9c0; }

/* عناصر الموبايل مخفية على الشاشات الكبيرة */
.gh-mobilebar, .gh-backdrop { display: none; }

/* ==========================================================================
   الشريط العلوي
   ========================================================================== */
.gh-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.gh-heading h1 { font-size: 24px; font-weight: 800; color: var(--gh-green-900); }
.gh-heading p { margin-top: 4px; font-size: 13.5px; color: var(--gh-muted); }
.gh-top-actions { display: flex; align-items: center; gap: 10px; }

.gh-search {
    display: flex; align-items: center; gap: 10px;
    width: 340px; max-width: 100%;
    padding: 0 14px; height: 46px;
    background: var(--gh-surface);
    border: 1px solid var(--gh-border); border-radius: var(--gh-r-ctrl);
    color: var(--gh-muted);
}
.gh-search:focus-within { border-color: var(--gh-green-600); box-shadow: 0 0 0 3px var(--gh-green-100); }
.gh-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 14px; color: var(--gh-text); }

.gh-icon-btn {
    position: relative;
    width: 46px; height: 46px;
    display: grid; place-items: center;
    background: var(--gh-surface);
    border: 1px solid var(--gh-border); border-radius: var(--gh-r-ctrl);
    color: var(--gh-green-700); cursor: pointer;
}
.gh-icon-btn:hover { background: var(--gh-green-50); }
.gh-dot { position: absolute; top: 11px; inset-inline-end: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--gh-orange); border: 2px solid #fff; }

/* ==========================================================================
   بطاقة الترحيب
   ========================================================================== */
.gh-welcome {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding: 26px 30px;
    margin-bottom: 18px;
    background: linear-gradient(120deg, #e9f6ee 0%, #f7fbf4 60%, #fff 100%);
    border: 1px solid #d6eadf; border-radius: 22px;
}
/* دائرة ليمونية ناعمة كلمسة وحيدة في الخلفية */
.gh-welcome::after {
    content: ""; position: absolute;
    inset-inline-start: -60px; bottom: -90px;
    width: 240px; height: 240px; border-radius: 50%;
    background: radial-gradient(circle, rgba(140,198,63,.28), transparent 70%);
    pointer-events: none;
}
.gh-welcome-text { position: relative; z-index: 1; min-width: 0; }
.gh-welcome h2 { font-size: 22px; font-weight: 800; color: var(--gh-green-900); }
.gh-welcome p { margin-top: 6px; font-size: 14.5px; color: #4a655a; max-width: 520px; line-height: 1.7; }
.gh-quick { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.gh-welcome-badge {
    position: relative; z-index: 1; flex: none;
    text-align: center; padding: 14px 26px;
    background: #fff; border: 1px solid #d6eadf; border-radius: var(--gh-r-card);
}
.gh-welcome-badge strong { display: block; font-size: 34px; font-weight: 800; color: var(--gh-green-700); line-height: 1.1; }
.gh-welcome-badge span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--gh-muted); max-width: 130px; }

/* ───────────── الأزرار ───────────── */
.gh-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent; border-radius: var(--gh-r-ctrl);
    font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.gh-btn:active { transform: translateY(1px); }
.gh-btn-primary { background: var(--gh-green-700); color: #fff; }
.gh-btn-primary:hover { background: var(--gh-green-900); }
.gh-btn-soft { background: #eef7dc; color: #4d7a17; border-color: #dcebb8; }
.gh-btn-soft:hover { background: #e3f1c4; }
.gh-btn-ghost { background: #fff; color: var(--gh-green-700); border-color: var(--gh-border); }
.gh-btn-ghost:hover { background: var(--gh-green-50); }
.gh-btn-sm { padding: 8px 12px; font-size: 13px; }
.gh-btn-sm .ico { width: 16px; height: 16px; }

/* ==========================================================================
   المؤشرات
   ========================================================================== */
.gh-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.gh-stat { padding: 18px; background: var(--gh-surface); border: 1px solid var(--gh-border); border-radius: var(--gh-r-card); }
.gh-stat-top { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; font-weight: 600; color: var(--gh-muted); }
.gh-stat-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--tint); color: var(--tone); }
.gh-stat-value { margin: 10px 0 2px; font-size: 30px; font-weight: 800; color: var(--gh-text); line-height: 1.2; }
.gh-stat small { font-size: 12.5px; color: var(--gh-muted); }

/* ==========================================================================
   الكروت العامة
   ========================================================================== */
.gh-grid-2 { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 16px; margin-bottom: 18px; }
.gh-grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.gh-card { padding: 22px; background: var(--gh-surface); border: 1px solid var(--gh-border); border-radius: var(--gh-r-card); }
.gh-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.gh-card-head h3 { font-size: 16.5px; font-weight: 800; color: var(--gh-green-900); }
.gh-card-head p { margin-top: 3px; font-size: 13px; color: var(--gh-muted); }
.gh-pill { padding: 5px 12px; border-radius: 999px; background: #fff3df; color: #9a6a1a; font-size: 12px; font-weight: 700; }

.gh-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gh-select {
    height: 38px; padding: 0 12px;
    border: 1px solid var(--gh-border); border-radius: 10px;
    background: #fff; color: var(--gh-text); font: inherit; font-size: 13px;
}

/* ───────────── جدول الحضور ───────────── */
.gh-table-scroll { overflow-x: auto; border: 1px solid var(--gh-border); border-radius: 14px; }
.gh-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 14px; }
.gh-table th {
    padding: 12px 14px; background: #f7faf8;
    font-size: 12.5px; font-weight: 700; color: var(--gh-muted); text-align: start;
    border-bottom: 1px solid var(--gh-border);
}
.gh-table td { padding: 13px 14px; border-bottom: 1px solid #eef2ef; }
.gh-table tbody tr:hover { background: #fafcfb; }
.gh-table tfoot td { background: var(--gh-green-50); font-weight: 800; border-bottom: 0; }
.gh-col-rate { width: 26%; }
.gh-branch { font-weight: 700; }
.gh-n-present { color: #1f8a64; font-weight: 700; }
.gh-n-leave   { color: #b9822a; font-weight: 700; }
.gh-n-absent  { color: #c25c47; font-weight: 700; }
.gh-empty-row td { padding: 34px 14px; text-align: center; color: var(--gh-muted); }

.gh-rate { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.gh-rate > span:first-child { min-width: 40px; }
.gh-bar { flex: 1; height: 8px; border-radius: 99px; background: #eaf0ec; overflow: hidden; }
.gh-bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--gh-green-600); }
.gh-bar-fill.warn { background: var(--gh-orange); }

.gh-hint-mobile { display: none; margin-top: 8px; font-size: 12px; color: var(--gh-muted); }
.gh-note { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12.5px; color: var(--gh-muted); }
.gh-note .ico { width: 15px; height: 15px; }

/* ───────────── الدونات والملخص ───────────── */
.gh-gauge { display: flex; align-items: center; justify-content: center; gap: 26px; flex-wrap: wrap; padding: 6px 0 4px; }
.gh-donut { width: 168px; height: 168px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.gh-donut-inner { width: 70%; height: 70%; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 50%; background: #fff; }
.gh-donut-inner strong { font-size: 28px; font-weight: 800; line-height: 1.1; }
.gh-donut-inner span { font-size: 12px; color: var(--gh-muted); }
.gh-legend { display: grid; gap: 10px; font-size: 14px; }
.gh-legend > div { display: flex; align-items: center; gap: 8px; }
.gh-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.gh-legend strong { margin-inline-start: auto; padding-inline-start: 14px; }

.gh-lines { margin-top: 18px; border-top: 1px solid var(--gh-border); }
.gh-lines > div { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; font-size: 13.5px; border-bottom: 1px dashed #e5ece8; }
.gh-lines > div:last-child { border-bottom: 0; }
.gh-lines span { color: var(--gh-muted); }
.gh-lines strong { text-align: end; }

/* ==========================================================================
   كروت الأنظمة
   ========================================================================== */
.gh-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.gh-section-title h2 { font-size: 19px; font-weight: 800; color: var(--gh-green-900); }
.gh-section-title small { font-size: 13px; color: var(--gh-muted); }

.gh-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 18px; }
.gh-module {
    display: flex; flex-direction: column; gap: 8px;
    padding: 20px;
    background: var(--gh-surface); border: 1px solid var(--gh-border); border-radius: var(--gh-r-card);
    color: inherit; text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
/* التفاعل عند المرور فقط على الكروت القابلة للضغط (مش كل العناصر) */
.gh-module:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(20, 60, 45, .08); }
.gh-module-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--tint); color: var(--accent); }
.gh-module h3 { margin-top: 6px; font-size: 16px; font-weight: 800; }
.gh-module p { font-size: 13px; color: var(--gh-muted); line-height: 1.7; flex: 1; }
.gh-module-cta { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13.5px; font-weight: 800; color: var(--accent); }
.gh-module-cta .ico { width: 16px; height: 16px; }

/* ───────────── القوائم والحالات الفارغة ───────────── */
.gh-empty { padding: 30px 16px; text-align: center; font-size: 13.5px; line-height: 1.8; color: var(--gh-muted); background: #f8faf9; border: 1px dashed var(--gh-border); border-radius: 14px; }
.gh-list { display: grid; gap: 8px; }
.gh-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--gh-border); border-radius: 12px; font-size: 13.5px; }
.gh-list-main { flex: 1; font-weight: 700; }
.gh-tag { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #eef2ef; color: #4a655a; }
.gh-tag.green  { background: #e0f3e9; color: #1d7a58; }
.gh-tag.orange { background: #fff0d9; color: #a2691a; }
.gh-tag.red    { background: #fde8e3; color: #b0482f; }
.gh-tag.blue   { background: #e5eefa; color: #3f6ea6; }
.gh-link { border: 0; background: none; color: var(--gh-green-700); font: inherit; font-weight: 800; cursor: pointer; }

.gh-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--gh-border); font-size: 12.5px; color: var(--gh-muted); }

/* ───────────── Toast ───────────── */
.gh-toast {
    position: fixed; inset-inline-start: 24px; bottom: 24px; z-index: 200;
    display: flex; align-items: center; gap: 14px;
    max-width: min(440px, calc(100vw - 48px));
    padding: 14px 18px;
    background: var(--gh-green-900); color: #fff;
    border-radius: 14px; font-size: 14px;
    box-shadow: 0 10px 30px rgba(10, 40, 30, .28);
}
.gh-toast button { border: 0; background: none; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }

/* ==========================================================================
   الاستجابة (Responsive)
   ========================================================================== */
@media (max-width: 1200px) {
    .gh-grid-2, .gh-grid-even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .gh-shell { grid-template-columns: minmax(0, 1fr); }
    .gh-main { padding: 78px 16px 28px; } /* مساحة للشريط العلوي الثابت */

    /* القائمة تتحول لدرج يطلع من اليمين (اتجاه RTL) */
    .gh-sidebar {
        position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
        width: min(300px, 86vw); height: 100dvh;
        transform: translateX(100%);
        transition: transform .25s ease;
        box-shadow: none;
    }
    .gh-sidebar.open { transform: translateX(0); box-shadow: -12px 0 40px rgba(10, 40, 30, .2); }

    .gh-mobilebar {
        position: fixed; top: 0; inset-inline: 0; height: 60px; z-index: 50;
        display: flex; align-items: center; gap: 12px; padding: 0 14px;
        background: #fff; border-bottom: 1px solid var(--gh-border);
        direction: rtl;
    }
    .gh-mobilebar strong { flex: 1; font-size: 15px; color: var(--gh-green-900); }
    .gh-mobilebar img { height: 36px; }
    .gh-hamburger { width: 42px; height: 42px; display: grid; place-content: center; gap: 4px; border: 1px solid var(--gh-border); border-radius: 12px; background: #fff; cursor: pointer; }
    .gh-hamburger span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--gh-green-700); }

    .gh-backdrop {
        display: block; position: fixed; inset: 0; z-index: 55;
        background: rgba(10, 30, 24, .45);
        opacity: 0; pointer-events: none; transition: opacity .25s ease;
    }
    .gh-backdrop.show { opacity: 1; pointer-events: auto; }

    .gh-search { width: 100%; }
    .gh-top-actions { width: 100%; }
    .gh-welcome { flex-direction: column; align-items: stretch; padding: 22px 18px; }
    .gh-welcome-badge { align-self: flex-start; }
    .gh-hint-mobile { display: block; }
}

/* احترام إعداد «تقليل الحركة» في نظام المستخدم */
@media (prefers-reduced-motion: reduce) {
    .gh-shell *, .gh-shell *::before, .gh-shell *::after { transition: none !important; }
}

/* توحيد القائمة في صفحات البوابة كلها بدون تحميل عناصر إضافية على Home */
.gh-layout-content{min-width:0;width:100%;overflow-x:hidden}
.gh-layout-content>.bm-page,.gh-layout-content>.tr-page{max-width:100%}
.gh-sidebar{overflow:hidden}.gh-nav{overscroll-behavior:contain}
@media(max-width:900px){.gh-layout-content{padding-top:53px}.gh-layout-content>.gh-main{padding-top:18px}}
