:root {
    --sg-dark: #1c2530;
    --sg-dark-2: #232f3d;
    --sg-amber: #f5a623;
    --sg-amber-dark: #d68910;
    --sg-bg: #f4f6f9;
    --sg-border: #e3e7ed;
}

* { box-sizing: border-box; }

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--sg-bg);
    margin: 0;
    color: #2b2f36;
}

a { text-decoration: none; }

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sg-dark);
    color: #cfd6e0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.1rem 1.2rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { color: var(--sg-amber); font-size: 1.4rem; }
.sidebar-brand small { font-weight: 400; color: #9aa5b1; font-size: .7rem; display: block; }
.brand-logo { height: 36px; width: auto; flex-shrink: 0; }
.login-logo { height: 64px; width: auto; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
}
.sidebar-user .avatar {
    width: 38px; height: 38px;
    background: var(--sg-amber);
    color: #1c2530;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.sidebar-nav { padding: .6rem 0; flex: 1; }
.sidebar-nav .nav-link {
    color: #cfd6e0;
    padding: .65rem 1.2rem;
    display: flex; align-items: center; gap: .7rem;
    font-size: .93rem;
    border-right: 3px solid transparent;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--sg-dark-2);
    color: var(--sg-amber);
    border-right-color: var(--sg-amber);
    font-weight: 600;
}

/* موديولات قابلة للطي في القائمة الجانبية */
.sidebar-nav .nav-link.has-children { justify-content: space-between; cursor: pointer; }
.sidebar-nav .nav-link.has-children span { display: flex; align-items: center; gap: .7rem; }
.sidebar-caret { font-size: .7rem !important; width: auto !important; transition: transform .2s ease; opacity: .6; }
.sidebar-nav a[aria-expanded="true"] .sidebar-caret { transform: rotate(180deg); opacity: 1; }
.sidebar-submenu { padding: .15rem 0 .4rem; }
.sidebar-submenu .nav-link {
    padding: .48rem 1.2rem .48rem 1.2rem;
    padding-right: 2.9rem;
    font-size: .85rem;
    color: #9aa5b1;
    border-right: 3px solid transparent;
}
.sidebar-submenu .nav-link:hover { background: rgba(255,255,255,.04); color: #fff; }
.sidebar-submenu .nav-link.active {
    background: var(--sg-dark-2);
    color: var(--sg-amber);
    border-right-color: var(--sg-amber);
    font-weight: 600;
}

/* ===== Main content ===== */
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: .8rem;
    background: #fff;
    border-bottom: 1px solid var(--sg-border);
    padding: .8rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-content { padding: 1.5rem; flex: 1; }

/* ===== Cards / KPI ===== */
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.1rem 1.3rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid var(--sg-border);
    height: 100%;
}
.kpi-card .kpi-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: .6rem;
}
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; }
.kpi-card .kpi-label { color: #6b7280; font-size: .85rem; }

.bg-amber { background: var(--sg-amber) !important; }

.card {
    border: 1px solid var(--sg-border);
    border-radius: 12px;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--sg-border);
    font-weight: 600;
}

.table thead th {
    background: #f8f9fb;
    font-size: .82rem;
    color: #6b7280;
    font-weight: 600;
    border-bottom: 1px solid var(--sg-border);
    white-space: nowrap;
}
.table td { vertical-align: middle; font-size: .9rem; }

.btn-amber {
    background: var(--sg-amber);
    border-color: var(--sg-amber);
    color: #1c2530;
    font-weight: 600;
}
.btn-amber:hover { background: var(--sg-amber-dark); border-color: var(--sg-amber-dark); color: #1c2530; }

.badge { font-weight: 500; }

.required::after { content: " *"; color: #dc3545; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; right: -260px; z-index: 1050; transition: right .25s; }
    .sidebar.show { right: 0; }
}

/* ===== Print (Quotations) ===== */
@media print {
    .no-print { display: none !important; }
    .page-content { padding: 0; }
    body { background: #fff; }
}

/* ===== مربع بحث العميل القابل للكتابة (Customer search combobox) ===== */
/* يُستخدم فى شاشات: نقطة البيع، عرض السعر، أمر البيع، فاتورة المبيعات */
.customer-search-wrap { position: relative; }
.customer-search-results {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 1060;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--sg-border);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
    margin-top: 2px;
}
.customer-search-item {
    padding: .5rem .75rem;
    font-size: .88rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f6;
}
.customer-search-item:last-child { border-bottom: none; }
.customer-search-item:hover, .customer-search-item.active { background: #fdf3e2; }
.customer-search-item .csi-phone { color: #8a93a1; font-size: .8rem; }
.customer-search-empty { padding: .6rem .75rem; font-size: .85rem; color: #8a93a1; text-align: center; }
