/* =========================================================
   نظام ERP - التصميم العام
   ========================================================= */

:root {
    --bg-body: #f4f6f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e2a3a;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0b1220;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
    font-family: 'Cairo', 'Tajawal', system-ui, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    transition: background .2s ease, color .2s ease;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #cbd5e1;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .25s ease;
}
.app-sidebar .brand {
    height: var(--topbar-height);
    display: flex; align-items: center; gap: .6rem;
    padding: 0 1.25rem;
    font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-sidebar .nav-link {
    color: #b8c2d1;
    padding: .65rem 1.25rem;
    display: flex; align-items: center; gap: .75rem;
    border-radius: 0;
    font-size: .92rem;
}
.app-sidebar .nav-link:hover,
.app-sidebar .nav-link.active {
    background: rgba(37,99,235,.15);
    color: #fff;
    border-right: 3px solid var(--primary);
}
.app-sidebar .nav-section-title {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: #64748b; padding: 1rem 1.25rem .35rem;
}

/* ---------- Main content ---------- */
.app-main {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
}
.app-topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 1020;
}
.app-content { padding: 1.5rem; }

@media (max-width: 991.98px) {
    .app-main { margin-right: 0; }
    .app-sidebar { transform: translateX(100%); }
    .app-sidebar.show { transform: translateX(0); }
}

/* ---------- Cards & widgets ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-card {
    border-radius: var(--radius);
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    position: absolute; left: 1rem; top: 1rem;
    font-size: 2.2rem; opacity: .35;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-label { font-size: .85rem; opacity: .9; }
.bg-grad-blue   { background: linear-gradient(135deg,#2563eb,#1e40af); }
.bg-grad-green  { background: linear-gradient(135deg,#16a34a,#166534); }
.bg-grad-orange { background: linear-gradient(135deg,#f59e0b,#b45309); }
.bg-grad-red    { background: linear-gradient(135deg,#ef4444,#b91c1c); }
.bg-grad-purple { background: linear-gradient(135deg,#8b5cf6,#5b21b6); }

/* ---------- Tables ---------- */
.table { color: var(--text-main); }
.table thead th {
    background: var(--bg-body);
    font-size: .82rem; text-transform: uppercase; color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}
.table td, .table th { vertical-align: middle; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border-color);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(37,99,235,.15);
}

/* ---------- Buttons ---------- */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* ---------- Theme toggle ---------- */
.theme-toggle-btn {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color); background: var(--bg-body);
    cursor: pointer;
}

/* ---------- Loading skeleton for tables ---------- */
.skeleton-row td {
    background: linear-gradient(90deg, var(--bg-body) 25%, var(--border-color) 37%, var(--bg-body) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    height: 42px;
}
@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ---------- POS screen ---------- */
.pos-product-card {
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    text-align: center;
    padding: .6rem;
    transition: transform .1s ease;
}
.pos-product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pos-cart-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    height: calc(100vh - var(--topbar-height) - 3rem);
}
