/* 1. استيراد الخطوط */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* 2. المتغيرات */
:root {
    --brand-red: #C8102E;
    --brand-red-light: #fdf0f2;
    --dark-text: #2d3436;
    --light-text: #636e72;
    --white: #FFFFFF;
    --bg-color: #f0f2f5;
    --border-color: #dee2e6;
    --sidebar-width: 250px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--dark-text);
    margin: 0;
    overflow-x: hidden;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================================ */
/* === SIDEBAR === */
/* ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: margin-left 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: #fdfdfd;
}

.logo {
    max-width: 180px;
    height: auto;
}

.sidebar-nav {
    padding: 15px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--light-text);
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    border-left: 4px solid transparent;
    border-radius: 0;
    margin-bottom: 0;
}

.nav-item:hover {
    background-color: var(--brand-red-light);
    color: var(--brand-red);
    border-left-color: var(--brand-red);
}

.nav-item.active {
    background-color: var(--brand-red);
    color: var(--white);
    border-left-color: transparent;
    font-weight: 600;
}

/* زر التثبيت */
.nav-item.install-item {
    margin-top: 20px;
    background-color: #fff5f6;
    color: var(--brand-red);
    border: 1px dashed var(--brand-red);
    justify-content: center;
    font-weight: 700;
}

.nav-item.install-item:hover {
    background-color: var(--brand-red);
    color: white;
    border-style: solid;
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    justify-content: space-between;
}

.dropdown-toggle::after {
    content: '▾';
    font-size: 1.2em;
    transition: transform 0.3s;
    margin-left: 10px;
}

.dropdown-toggle.active::after {
    transform: rotate(180deg);
    color: var(--white);
}

.dropdown-toggle:hover::after {
    color: var(--brand-red);
}

.dropdown-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #fcfcfc;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-content.open {
    max-height: 500px;
    transition: max-height 0.3s ease-in;
}

.dropdown-link {
    display: block;
    padding: 10px 20px 10px 35px;
    text-decoration: none;
    color: var(--light-text);
    font-size: 13px;
    border-left: 4px solid transparent;
    transition: all 0.2s;
}

.dropdown-link:hover {
    background-color: var(--brand-red-light);
    color: var(--brand-red);
    padding-left: 40px;
}

/* ============================================================ */
/* === MAIN CONTENT === */
/* ============================================================ */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    transition: margin-left 0.3s ease;
    width: calc(100% - var(--sidebar-width));
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 15px 25px;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 15px;
    /* 👇👇👇 التعديلات المطلوبة للتثبيت 👇👇👇 */
    position: sticky;
    /* يجعل العنصر يلتصق */
    top: 10px;
    /* المسافة من أعلى الشاشة (10 بكسل لترك فراغ جمالي) */
    z-index: 900;
    /* لضمان ظهوره فوق باقي المحتوى */
    margin-bottom: 20px;
    /* مسافة بينه وبين الكروت تحته */
    /* 👆👆👆 ------------------------- 👆👆👆 */
}

.main-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-text);
    letter-spacing: -0.5px;
}

.controls-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

#month-filter {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 14px;
    background-color: #fafafa;
    color: var(--dark-text);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

#month-filter:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

/* Cards */
.card {
    background-color: var(--white);
    padding: 25px;
    border-radius: 20px;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.card h2 {
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
    color: var(--dark-text);
    border-left: 4px solid var(--brand-red);
    padding-left: 10px;
}

/* KPI */
.total-kpi {
    text-align: center;
    padding: 10px;
}

#total-hours-card {
    background: linear-gradient(135deg, var(--brand-red) 0%, #a00d25 100%);
    color: var(--white);
}

#total-hours-card .kpi-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

#total-hours-card .kpi-value {
    color: var(--white);
    font-size: 3.5rem;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
}

.kpi-card {
    background: var(--white);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    transition: var(--transition);
}

.kpi-card:hover {
    border-color: var(--brand-red-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--light-text);
    margin-bottom: 10px;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark-text);
}

.row-3-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

/* Charts */
.bar {
    fill: var(--brand-red);
    rx: 4;
}

.bar:hover {
    opacity: 0.85;
    filter: drop-shadow(0 4px 6px rgba(200, 16, 46, 0.4));
}

.arc-path {
    cursor: pointer;
    stroke: var(--white);
    stroke-width: 3px;
}

.line {
    fill: none;
    stroke: var(--brand-red);
    stroke-width: 4px;
    stroke-linecap: round;
}

.area {
    fill: url(#area-gradient);
    opacity: 0.6;
    stroke: none;
}

.axis-x text,
.axis-y text {
    font-size: 11px;
    fill: #888;
}

.axis-x path,
.axis-y path {
    display: none;
}

.axis-x line,
.axis-y line {
    stroke: #eee;
    stroke-dasharray: 4;
}

.bar-label {
    font-size: 11px;
    font-weight: 600;
    fill: var(--dark-text);
    text-anchor: middle;
    pointer-events: none;
}

.legend-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    background: #f9f9f9;
    padding: 5px 10px;
    border-radius: 20px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.install-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
}

.main-install-btn {
    background-color: var(--brand-red);
    color: var(--white);
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(200, 16, 46, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-install-btn:hover {
    background-color: #a00d25;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(200, 16, 46, 0.4);
}

.site-footer {
    text-align: center;
    padding: 30px;
    color: #999;
    font-size: 13px;
    background: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* === RESPONSIVE === */
.logo-mobile,
.sidebar-toggle,
.mobile-header-top {
    display: none;
}

@media screen and (max-width: 1024px) {
    .row-3-container {
        grid-template-columns: 1fr 1fr;
    }
}

@media screen and (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 100px rgba(0, 0, 0, 0.5);
        border-right: none;
    }

    .sidebar.visible {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 15px;
        width: 100%;
    }

    .main-header {
        flex-direction: column;
        padding: 15px;
        gap: 20px;
        position: sticky;
        top: 0;
        /* في الموبايل نجعله 0 ليلتصق تماماً بالحافة */
        border-radius: 0 0 16px 16px;
        /* تدوير الحواف السفلية فقط */
        z-index: 900;

    }

    .mobile-header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .logo-mobile {
        display: block;
        height: 45px;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--white);
        color: var(--dark-text);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        font-size: 22px;
        cursor: pointer;
        width: 45px;
        height: 45px;
        box-shadow: var(--shadow-sm);
    }

    .controls-container,
    .filter-container,
    #month-filter {
        width: 100%;
        text-align: center;
    }

    .row-3-container {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .kpi-value {
        font-size: 1.5rem !important;
    }

    #total-hours-card .kpi-value {
        font-size: 2.5rem !important;
    }

    .card {
        padding: 15px;
    }
}

/* ============================================================ */
/* === MODAL & TABLE (FIXED SCROLL & STYLE) === */
/* ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--white);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow-lg);
    width: 95%;
    max-width: 800px;
    max-height: 85vh;
    /* أقصى ارتفاع للنافذة */
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--brand-red);
    padding-bottom: 15px;
    margin-bottom: 15px;
    flex-shrink: 0;
    /* الهيدر ثابت لا ينكمش */
}

.modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--brand-red);
}

.close-button {
    background: #f1f1f1;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #555;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-button:hover {
    background: var(--brand-red);
    color: white;
}

/* 👇👇👇 الحاوية المسؤولة عن السكرول 👇👇👇 */
#modal-table-container {
    overflow-y: auto;
    /* سكرول رأسي */
    overflow-x: auto;
    /* سكرول أفقي (للجدول العريض) */
    width: 100%;
    border: 1px solid var(--border-color);
    /* إطار خفيف */
}

/* 👇👇👇 تصميم الجدول الكلاسيكي الواضح 👇👇👇 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    white-space: nowrap;
    /* يمنع النص من الانثناء، مما يجبر السكرول عند الحاجة */
}

.data-table th {
    background-color: var(--brand-red);
    color: var(--white);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #b00c24;
    position: sticky;
    /* تثبيت الرأس عند السكرول */
    top: 0;
}

.data-table td {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    color: var(--dark-text);
}

.data-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.data-table tr:hover {
    background-color: #fff5f6;
}

/* === تنسيق السنوات داخل القائمة === */

/* 1. شكل عنوان السنة (2025) */
.year-header {
    padding: 8px 20px 8px 30px;
    /* مسافة مريحة */
    font-size: 13px;
    font-weight: 700;
    /* خط عريض */
    color: var(--brand-red);
    /* لون أحمر لتمييز السنة */
    background-color: #f1f1f1;
    /* خلفية رمادية خفيفة جداً */
    cursor: default;
    /* الماوس ميتغيرش لأنه مش رابط */
    border-bottom: 1px solid #e0e0e0;
    margin-top: 5px;
}

/* 2. الروابط المتفرعة (تحت السنة) */
.dropdown-link.nested-link {
    padding-left: 45px !important;
    /* إزاحة للداخل أكثر من الطبيعي */
    font-size: 12.5px;
    border-left: 4px solid transparent;
}

/* 3. تأثير عند الوقوف على الرابط المتفرع */
.dropdown-link.nested-link:hover {
    padding-left: 50px !important;
    /* حركة بسيطة */
    background-color: #fff0f2;
    border-left-color: var(--brand-red);
}

/* === تنسيق القوائم الفرعية (Nested Dropdowns) === */

/* زر السنة (2025) */
.sub-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--dark-text) !important;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

/* السهم الصغير جنب السنة */
.sub-toggle .arrow {
    font-size: 1.2em;
    transition: transform 0.3s ease;
    margin-right: 5px;
}

/* دوران السهم عند الفتح */
.sub-toggle.active .arrow {
    transform: rotate(90deg);
    color: var(--brand-red);
}

.sub-toggle.active {
    color: var(--brand-red) !important;
    background-color: #fff5f6;
}

/* حاوية الروابط (مخفية افتراضياً) */
.sub-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #ffffff;
    border-left: 2px solid var(--brand-red-light);
    /* خط جمالي */
}

.sub-content.open {
    max-height: 300px;
    /* ارتفاع كافي للمحتوى */
    transition: max-height 0.3s ease-in;
}

/* الروابط الداخلية */
.nested-link {
    padding-left: 40px !important;
    /* إزاحة للداخل */
    font-size: 12.5px;
    color: #666;
}

.nested-link:hover {
    background-color: var(--brand-red-light);
    color: var(--brand-red);
}
