/* ---------------------------------------------------
   1) الاستيراد و Reset
--------------------------------------------------- */

/* خط تجوال */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
    font-family: inherit;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}


/* ---------------------------------------------------
   2) الثيمات (Light / Dark)
--------------------------------------------------- */

body.theme-light {
    --bg-color: #f3f4f6;
    --bg-card: #ffffff;
    --bg-sidebar: #111827;
    --bg-header: #111827;
    --text-color: #111827;
    --text-muted: #6b7280;

    --primary: #2563eb;
    --primary-soft: rgba(37, 99, 235, 0.1);

    --border-color: #e5e7eb;
}

body.theme-dark {
    --bg-color: #060818; /* مثل Cuba */
    --bg-card: #0b1120;
    --bg-sidebar: #050816;
    --bg-header: #060818;
    --text-color: #e5e7eb;
    --text-muted: #9ca3af;

    --primary: #6366f1;
    --primary-soft: rgba(99, 102, 241, 0.12);

    --border-color: #1f2937;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}


/* ---------------------------------------------------
   3) RTL / LTR
--------------------------------------------------- */

body.lang-ar {
    direction: rtl;
    text-align: right;
}

body.lang-en {
    direction: ltr;
    text-align: left;
}


/* ---------------------------------------------------
   4) Layout
--------------------------------------------------- */

.layout {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}


/* ---------------------------------------------------
   5) Sidebar
--------------------------------------------------- */

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    height: 100vh;

    /* Scroll فقط عند Hover (الـ overflow-y النهائية بتتظبط من header.php) */
    overflow-y: hidden;
}
.sidebar:hover {
    overflow-y: auto;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 0;
}
.sidebar:hover::-webkit-scrollbar {
    width: 7px;
}
.sidebar:hover::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
}
.sidebar:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

/* Sidebar المحتوى */
.sidebar .brand {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 2rem;
    text-align: center;
}

.sidebar .nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.sidebar .nav a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 0.9rem;
    border-radius: 0.6rem;
    text-decoration: none;
    color: #e5e7eb;
    font-size: 1rem;           /* رجعنا الحجم الطبيعي */
    font-weight: 500;
    margin-bottom: 0.25rem;
    transition: 0.2s;
}

/* الأيقونة داخل اللينك */
.sidebar .nav a .icon {
    font-size: 1.05rem;
}

/* الـ active الذهبي */
.sidebar .nav a.active {
    background: rgba(249, 209, 62, 0.16);
    border-inline-start: 4px solid #f9d13e; /* يمين في العربي / شمال في الإنجليزي */
    color: #ffffff;
    box-shadow: inset 0 0 8px rgba(249, 209, 62, 0.35);
}

.sidebar .nav a:hover {
    background: rgba(255,255,255,0.12);
}


/* ---------------------------------------------------
   6) Main + Header
--------------------------------------------------- */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.header {
    background-color: var(--bg-header);
    color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.3rem;

    /* الوضع الافتراضي sticky، و header.php بيحدد sticky/static بالكلاسات */
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 8px 20px rgba(15,23,42,0.35);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.header-btn {
    border: 1px solid rgba(148,163,184,0.45);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.header-btn:hover {
    background-color: rgba(148,163,184,0.2);
}

.header-lang a {
    color: inherit;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
}
.header-lang a.active {
    background-color: rgba(148,163,184,0.3);
}


/* ---------------------------------------------------
   7) Content Wrapper
--------------------------------------------------- */

.content {
    padding: 1.25rem;
    padding-bottom: 80px; /* مساحة فوق الفوتر */
}


/* ---------------------------------------------------
   8) Cards
--------------------------------------------------- */

.card {
    background-color: var(--bg-card);
    border-radius: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 30px rgba(15,23,42,0.25);
}


/* ---------------------------------------------------
   9) Tables
--------------------------------------------------- */

.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.table th,
.table td,
.data-table th,
.data-table td {
    padding: 0.65rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.table th,
.data-table th {
    text-align: start;
    color: var(--text-muted);
    font-weight: 600;
}

.data-table tbody tr:hover {
    background: rgba(255,255,255,0.06);
}


/* ---------------------------------------------------
   10) Inputs & Buttons
--------------------------------------------------- */

.input,
input,
select,
textarea {
    padding: 0.45rem 0.7rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-color);
    font-size: 0.9rem;
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-soft);
}

/* Buttons */
.btn {
    padding: 0.45rem 0.9rem;
    border-radius: 0.55rem;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary));
    color: #fff;
}

.btn-primary:hover {
    filter: brightness(1.12);
}


/* ---------------------------------------------------
   11) Alerts
--------------------------------------------------- */

.alert {
    padding: 0.7rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 0.85rem;
    font-size: 0.87rem;
}

.alert-success {
    background: rgba(22,163,74,0.2);
    color: #4ade80;
}

.alert-danger {
    background: rgba(220,38,38,0.2);
    color: #fca5a5;
}


/* ============================
   12) FOOTER — ثابت ومتناسق مع الثيم
   ============================ */

/* الفوتر داخل div.main → استخدمنا .main > .app-footer */
.main > .app-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    box-shadow: 0 -8px 20px rgba(0,0,0,0.08);
    position: relative;
    z-index: 10;
}

/* نص الحقوق */
.main > .app-footer .footer-brand {
    font-weight: 700;
    color: var(--primary);
}



/* ---------------------------------------------------
   13) Responsive Tweaks (Mobile)
--------------------------------------------------- */

@media (max-width: 768px) {
    .header {
        padding: 0.6rem 0.8rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-title {
        font-size: 1rem;
    }

    .header-left,
    .header-right {
        flex-wrap: wrap;
    }

    .content {
        padding: 0.9rem;
    }

    .card {
        padding: 0.9rem;
    }

    .table,
    .data-table {
        font-size: 0.8rem;
    }

    .table th,
    .table td,
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.35rem;
    }
}

/* ========== Sidebar Drawer Mobile ========== */
@media (max-width: 768px) {

    /* زر الهامبورجر في الهيدر */
    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        margin-inline-end: 8px;
        border-radius: 999px;
        border: 1px solid rgba(148,163,184,0.6);
        background: transparent;
        color: #e5e7eb;
        font-size: 1.4rem;
        cursor: pointer;
    }

    .mobile-menu-btn:hover {
        background-color: rgba(148,163,184,0.2);
    }

    /* السايدبار يتحول لـ Drawer ثابت خارج الشاشة */
    .sidebar {
        position: fixed !important;
        top: 0;
        bottom: 0;
        height: 100vh;
        width: 260px;
        padding: 1rem;
        background-color: var(--bg-sidebar);
        z-index: 200;
        overflow-y: auto;
        overflow-x: hidden;

        /* LTR: يختفي ناحية الشمال */
        left: 0;
        right: auto;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease;
    }

    /* عربي: يختفي ناحية اليمين */
    body.lang-ar .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%) !important;
    }

    /* عند الفتح */
    .sidebar.open {
        transform: translateX(0) !important;
    }

    body.lang-ar .sidebar.open {
        transform: translateX(0) !important;
    }

    /* زر إغلاق داخل السايدبار */
    .close-sidebar {
        display: block;
        background: transparent;
        border: none;
        color: #fff;
        font-size: 2rem;
        cursor: pointer;
        padding: 10px 0;
        text-align: start;
        width: 100%;
    }

    body.lang-ar .close-sidebar {
        text-align: end;
    }

    /* الخلفية السوداء الشفافة */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        display: none;
        z-index: 150;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* شوية ضبط للهيدر في الموبايل */
    .header {
        padding-left: 5px;
        padding-right: 5px;
    }
}


/* ========== FORCE Sidebar Drawer on Mobile ========== */
@media screen and (max-width: 900px) {

    body, html {
        overflow: auto !important;
        height: auto !important;
    }

    .layout {
        overflow: visible !important;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        bottom: 0;
        width: 260px !important;
        height: 100vh !important;
        background: var(--bg-sidebar);
        z-index: 9999 !important;
        overflow-y: auto !important;

        /* LTR */
        left: 0;
        right: auto;
        transform: translateX(-100%) !important;
        transition: transform 0.35s ease !important;
    }

    body.lang-ar .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%) !important;
    }

    .sidebar.open,
    body.lang-ar .sidebar.open {
        transform: translateX(0) !important;
    }

    /* Overlay */
    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 9998;
    }

    #sidebarOverlay.show {
        display: block !important;
    }
}

