﻿/* ============================================================
   ALJAWAL CAR - Layout / Structure Only (no colors, no theme)
   ============================================================ */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: sans-serif;
    font-size: var(--fs-md);
    direction: rtl;
}

/* ══════════════════════════════════════════
   SHELL LAYOUT
   ══════════════════════════════════════════ */

/* ── Top Bar ── */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--surface, #fff);
    border-bottom: 2px solid var(--border, #333);
    z-index: var(--z-topbar, 200);
    gap: 8px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#topbar-search-slot {
    width: 220px;
}

@media (max-width: 768px) {
    #topbar-search-slot {
        width: 140px;
    }
}

.top-bar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.logo-text {
    font-size: var(--fs-lg);
    font-weight: 800;
    letter-spacing: 2px;
}

.toggle-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-2);
}

.user-badge,
.session-info,
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--fs-sm);
    white-space: nowrap;
    cursor: pointer;
    border-radius: var(--radius-s);
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btn-logout {
    border-color: var(--border);
    font-weight: 600;
    color: var(--text-2);
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.session-timer {
    font-family: monospace;
    font-weight: 600;
}

.bottom-bar-admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--primary, #B8960C);
    background: transparent;
    font-size: var(--fs-sm);
    white-space: nowrap;
    cursor: pointer;
    font-family: sans-serif;
    font-weight: 600;
    color: var(--primary, #B8960C);
}

.bottom-bar-admin-btn:hover {
    background: var(--primary-t, rgba(184, 150, 12, 0.08));
}

/* ── Main Layout ── */
.main-container {
    display: flex;
    margin-top: 45px;
    height: calc(100vh - 45px - 36px);
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    right: 0;
    top: 45px;
    width: 248px;
    height: calc(100vh - 45px - 36px);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 18px 16px 14px;
    font-weight: 800;
    font-size: var(--fs-md);
    letter-spacing: 2.5px;
}

.sidebar-logo {
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    padding: 6px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar.collapsed {
    width: 56px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .nav-children,
.sidebar.collapsed .sidebar-header {
    display: none;
}

.sidebar.collapsed .sidebar-nav {
    padding: 8px 6px 16px;
    align-items: center;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px;
    margin: 0;
}

/* ── Content Area ── */
.content-area {
    flex: 1;
    margin-right: 248px;
    height: 100%;
    overflow-y: auto;
    background: var(--bg, #fafafa);
}

.content-wrapper {
    padding: 20px;
    padding-bottom: 56px;
    max-width: 1400px;
    background: var(--bg, #fafafa);
}

.sidebar.collapsed~.content-area {
    margin-right: 56px;
}

/* ── Bottom Bar ── */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px;
    gap: 8px;
    border-top: 1px solid var(--border-s);
    background: var(--surface);
    font-size: var(--fs-sm);
    z-index: var(--z-bottombar, 200);
}

/* ══════════════════════════════════════════
   NAVIGATION
   ══════════════════════════════════════════ */

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 0;
    cursor: pointer;
    user-select: none;
    border: none;
    border-radius: var(--radius-s, 6px);
    font-size: var(--fs-md);
    line-height: 1.3;
    position: relative;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon .icon {
    width: 18px;
    height: 18px;
}

.nav-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-children {
    display: none;
    padding: 2px 0 4px 0;
    margin: 0 8px 4px 4px;
    padding-right: 10px;
}

.nav-children.expanded {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-item[data-level="1"]>.nav-link {
    padding: 8px 12px 8px 10px;
    font-size: var(--fs-base);
    gap: 8px;
}

.nav-item[data-level="1"]>.nav-link::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.55;
}

.nav-arrow {
    width: 8px;
    height: 8px;
    margin-right: auto;
    margin-left: 4px;
    flex-shrink: 0;
    border-style: solid;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(-45deg);
    transition: transform var(--transition, 0.18s ease);
    opacity: 0.55;
    font-size: 0;
    color: transparent;
}

.nav-arrow.expanded {
    transform: rotate(45deg);
    opacity: 0.9;
}

.nav-popup {
    display: none;
    position: fixed;
    padding: 6px;
    min-width: 200px;
    z-index: 9999;
}

.nav-popup-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: var(--fs-base);
}

.nav-popup-group-title {
    padding: 8px 12px 6px;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* ── Breadcrumb ── */
#breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-sm);
    white-space: nowrap;
    overflow-x: auto;
}

#breadcrumb a {
    color: inherit;
    text-decoration: none;
}

#breadcrumb a:hover {
    text-decoration: underline;
}

#breadcrumb span {
    color: #888;
}

/* ── Icon ── */
.icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 499;
}

.sidebar-overlay.visible {
    display: block;
}

/* ══════════════════════════════════════════
   PWA / MOBILE LAYOUT
   ══════════════════════════════════════════ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.25s ease;
        z-index: 500;
        width: 280px !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .content-area {
        margin-right: 0 !important;
    }

    .main-container {
        height: calc(100vh - 45px - 36px);
    }

    .user-badge,
    .session-info {
        display: none;
    }

    .logo-text {
        font-size: var(--fs-base);
        letter-spacing: 1px;
    }

    #breadcrumb {
        display: none;
    }

    .content-wrapper {
        padding: 12px;
        padding-bottom: 80px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: var(--fs-lg);
    }

    .page-actions {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .bottom-bar {
        font-size: var(--fs-xs);
        padding: 0 8px;
    }

    .btn-logout span {
        display: none;
    }

    .bottom-bar-admin-btn span {
        display: none;
    }

    .form-row {
        flex-direction: column;
    }

    input,
    select,
    textarea {
        font-size: var(--fs-lg);
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
    }

    .modal-overlay,
    .modal {
        align-items: flex-end;
    }
}

/* iOS safe area و standalone PWA موجودة في pwa.css */