/* public/assets/css/app.css */

/* ==============================
   1) الفونت المحلي للمشروع
   ============================== */
@font-face {
    font-family: 'AppFont';
    src: url('../fonts/Almarai-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --app-bg: #0f172a;
    --app-bg-soft: #f5f6fa;
    --app-primary: #2563eb;
    --app-primary-soft: #e0edff;
    --app-primary-dark: #1d4ed8;
    --app-accent: #22c55e;
    --app-danger: #ef4444;
    --app-text-main: #0f172a;
    --app-text-muted: #6b7280;
    --app-sidebar-bg: #020617;
    --app-sidebar-border: rgba(148, 163, 184, .14);
    --app-topbar-bg: #ffffff;
    --app-card-bg: #ffffff;
    --app-sidebar-w: 260px;
}

html,
body {
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: 'AppFont', system-ui, -apple-system, "Segoe UI", sans-serif;
    background-color: var(--app-bg-soft);
    color: var(--app-text-main);
}

/* تثبيت الفونت المحلي القديم داخل السايدبار والقوائم */
.app-sidebar,
.app-sidebar *,
.app-sidebar button,
.app-sidebar a {
    font-family: 'AppFont', Tahoma, Arial, sans-serif !important;
    letter-spacing: 0 !important;
}

/* ==============================
   صفحة تسجيل الدخول
   ============================== */
.auth-page {
    min-height: 100vh;
    background: radial-gradient(circle at top right, #1d4ed8 0, #0f172a 40%, #020617 100%);
    color: #e5e7eb;
}

.auth-card {
    max-width: 420px;
    width: 100%;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(148, 163, 184, 0.2);
    background: linear-gradient(145deg, #0b1020, #020617);
    color: #e5e7eb;
}

.auth-card .form-control {
    background-color: rgba(15, 23, 42, 0.8);
    border-color: rgba(148, 163, 184, 0.4);
    color: #e5e7eb;
}

.auth-card .form-control:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 1px var(--app-primary);
    background-color: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
}

.auth-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.auth-title { font-weight: 600; }
.auth-subtitle { font-size: .85rem; color: #9ca3af; }
.auth-btn-primary { background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark)); border: none; font-weight: 600; }
.auth-btn-primary:hover { background: linear-gradient(135deg, var(--app-primary-dark), var(--app-primary)); }
.auth-card .alert { font-size: .85rem; }

/* ==============================
   Layout عام
   ============================== */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: row; /* السايدبار على الشمال كما كان */
    align-items: stretch;
    background-color: var(--app-bg-soft);
    width: 100%;
}

.app-wrapper,
.app-content {
    flex: 1 1 auto;
    width: calc(100% - var(--app-sidebar-w));
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    padding: 1.5rem;
    background: radial-gradient(circle at top left, #eff6ff 0, #f5f5f5 45%, #f9fafb 100%);
    overflow-x: hidden;
}

/* يخلي صفحات الإدارة القديمة تستفيد من العرض بالكامل بدل ما تصغر في النص */
.app-main > .container,
.app-main > .container-sm,
.app-main > .container-md,
.app-main > .container-lg,
.app-main > .container-xl,
.app-main > .container-xxl {
    max-width: 100%;
}

/* ==============================
   Sidebar
   ============================== */
.app-sidebar {
    flex: 0 0 var(--app-sidebar-w);
    width: var(--app-sidebar-w);
    max-width: var(--app-sidebar-w);
    min-height: 100vh;
    background: radial-gradient(circle at top left, #1d4ed8 0, #071a49 35%, #020617 76%, #000 100%);
    color: #e5e7eb;
    border-left: 1px solid var(--app-sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.app-sidebar-brand {
    min-height: 82px;
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.app-sidebar-logo-wrap {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: #fff;
    min-width: 0;
}

.app-sidebar-logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: rgba(255,255,255,.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(29,78,216,.22);
}

.app-sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.app-sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.app-sidebar-brand-text strong {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .2px;
}

.app-sidebar-brand-text small {
    font-size: .75rem;
    color: #38bdf8;
    font-weight: 700;
}

.app-sidebar-close,
.app-sidebar-toggle {
    border: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, .1);
    color: #1d4ed8;
    font-size: 1.25rem;
}

.app-sidebar-close {
    background: rgba(255,255,255,.09);
    color: #fff;
}

.app-sidebar-inner,
.app-sidebar-nav {
    padding: .75rem .75rem 1rem;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-sidebar-inner::-webkit-scrollbar,
.app-sidebar-nav::-webkit-scrollbar { width: 6px; }
.app-sidebar-inner::-webkit-scrollbar-thumb,
.app-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.35); border-radius: 999px; }

.app-sidebar-section-title {
    font-size: .7rem;
    text-transform: uppercase;
    color: #6b7280;
    padding: .5rem .75rem;
    letter-spacing: .06em;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .5rem;
    width: 100%;
    padding: .62rem .9rem;
    border-radius: 999px;
    color: #e5e7eb;
    font-size: .86rem;
    line-height: 1.4;
    text-decoration: none;
    margin-bottom: .25rem;
    transition: background .15s ease, color .15s ease, transform .05s ease;
}

.app-sidebar-link:hover {
    background: rgba(148, 163, 184, .15);
    color: #fff;
    transform: translateY(-1px);
}

.app-sidebar-link.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}

.app-sidebar-accordion-btn {
    width: 100%;
    padding: .62rem .9rem;
    background: transparent;
    border: 0;
    color: #cbd5e1;
    font-size: .84rem;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 999px;
    margin: .15rem 0;
}

.app-sidebar-accordion-btn:hover,
.app-sidebar-accordion-btn.active {
    color: #fff;
    background: rgba(148, 163, 184, .12);
}

.app-sidebar-accordion-icon {
    font-size: .78rem;
    opacity: .8;
}

/* ==============================
   Topbar
   ============================== */
.app-topbar {
    min-height: 64px;
    background: var(--app-topbar-bg);
    border-bottom: 1px solid #e5e7eb;
    padding: .75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.app-topbar-start {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.app-topbar-heading { min-width: 0; }

.app-topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--app-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-breadcrumb {
    font-size: .8rem;
    color: var(--app-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-user-box {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex: 0 0 auto;
}

.app-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--app-primary-soft);
    color: var(--app-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.app-user-name { font-size: .85rem; margin-bottom: 0; font-weight: 700; }
.app-user-role { font-size: .75rem; color: var(--app-text-muted); }

/* ==============================
   Cards / Common
   ============================== */
.app-card {
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, .35);
    background-color: var(--app-card-bg);
    box-shadow: 0 12px 25px rgba(15, 23, 42, .12), 0 0 0 1px rgba(148, 163, 184, .25);
}
.app-card-header { padding: 1rem 1.25rem .5rem; border-bottom: none; }
.app-card-title { font-size: .95rem; font-weight: 700; margin-bottom: .15rem; }
.app-card-subtitle { font-size: .8rem; color: var(--app-text-muted); }
.app-card-body { padding: .75rem 1.25rem 1rem; }

.app-quick-link {
    text-decoration: none;
    display: block;
    padding: .75rem .9rem;
    border-radius: 12px;
    font-size: .85rem;
    border: 1px solid #e5e7eb;
    color: var(--app-text-main);
    transition: background .15s ease, transform .08s ease, box-shadow .15s ease;
    background: #fff;
}
.app-quick-link:hover { background: #eff6ff; transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15, 23, 42, .12); }
.badge-soft-primary { background-color: var(--app-primary-soft); color: var(--app-primary-dark); }
.badge-soft-accent { background-color: #dcfce7; color: #15803d; }

.app-footer {
    padding: .6rem 1.5rem;
    font-size: .78rem;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* ==============================
   Responsive
   ============================== */
@media (max-width: 991.98px) {
    :root { --app-sidebar-w: 286px; }

    .app-shell {
        display: block;
        min-height: 100vh;
        width: 100%;
    }

    .app-wrapper,
    .app-content {
        width: 100%;
        min-width: 0;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        width: var(--app-sidebar-w);
        max-width: 86vw;
        height: 100vh;
        min-height: 100vh;
        z-index: 1050;
        transform: translateX(-110%);
        transition: transform .25s ease;
        box-shadow: 18px 0 34px rgba(0,0,0,.34);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, .55);
        z-index: 1040;
    }

    .app-topbar {
        min-height: 58px;
        height: auto;
        padding: .65rem .85rem;
        gap: .65rem;
    }

    .app-topbar-title { font-size: .95rem; max-width: 45vw; }
    .app-breadcrumb { display: none; }
    .app-user-box { gap: .45rem; }
    .app-user-avatar { width: 32px; height: 32px; font-size: .78rem; }
    .app-logout-btn { padding: .24rem .5rem; font-size: .75rem; }
    .app-main { padding: 1rem; }
    .app-footer { display: block; text-align: center; padding: .75rem; }
}

@media (max-width: 575.98px) {
    .app-main { padding: .75rem; }
    .app-topbar { padding: .55rem .65rem; }
    .app-topbar-title { max-width: 38vw; }
    .app-user-box .app-logout-btn { margin-inline-start: .15rem !important; }
}
