/* =====================================================================
   Anies Collection — Curtains Shop Management System
   Modern, Apple-inspired UI · RTL · Light/Dark
   ===================================================================== */

:root {
    --bg: #f0f0f0;
    --surface: #ffffff;
    --surface-2: #f0f0f0;
    --text: #3b3838;
    --text-muted: rgba(59, 56, 56, 0.7);
    --border: rgba(59, 56, 56, 0.22);
    --primary: #3b3838;
    --primary-hover: #2f2d2d;
    --success: #3b3838;
    --warning: #3b3838;
    --danger: #3b3838;
    --info: #3b3838;
    --shadow: 0 4px 20px rgba(0,0,0,.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.10);
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 260px;
    --font: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
    --bg: #3b3838;
    --surface: #3b3838;
    --surface-2: rgba(240, 240, 240, 0.08);
    --text: #f0f0f0;
    --text-muted: rgba(240, 240, 240, 0.78);
    --border: rgba(240, 240, 240, 0.2);
    --shadow: 0 4px 20px rgba(0,0,0,.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background .3s, color .3s;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    right: 0;
    left: auto;
    z-index: 100;
    transition: transform .3s;
}

.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 24px 22px;
    border-bottom: 1px solid var(--border);
}
.brand-logo {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--primary);
    color: #fff; font-weight: 800; font-size: 20px;
    display: grid; place-items: center;
    overflow: hidden;
}
.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.brand-name { font-weight: 800; font-size: 17px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-weight: 600; font-size: 15px;
    transition: background .2s, color .2s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ico { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.main {
    flex: 1;
    margin-inline-end: var(--sidebar-w);
    margin-right: var(--sidebar-w);
    margin-left: 0;
    display: flex; flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 64px;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 20px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.icon-btn {
    background: var(--surface-2); border: 1px solid var(--border);
    width: 40px; height: 40px; border-radius: 12px;
    font-size: 18px; cursor: pointer; color: var(--text);
    display: grid; place-items: center; transition: .2s;
}
.icon-btn:hover { background: var(--border); }
#menuToggle { display: none; }

.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary);
    color: #fff; font-weight: 700; display: grid; place-items: center;
}
.user-name { font-weight: 600; font-size: 14px; }

.content { padding: 28px; flex: 1; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.card + .card { margin-top: 20px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 17px; font-weight: 700; }

/* ---------- KPI Grid ---------- */
.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    position: relative; overflow: hidden;
}
.kpi-label { color: var(--text-muted); font-size: 14px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 8px; }
.kpi-icon {
    position: absolute; inset-block-start: 18px; inset-inline-start: 18px;
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center; font-size: 20px;
}
.kpi.blue .kpi-icon   { background: rgba(0,113,227,.12); color: var(--primary); }
.kpi.green .kpi-icon  { background: rgba(52,199,89,.14); color: var(--success); }
.kpi.red .kpi-icon    { background: rgba(255,59,48,.14); color: var(--danger); }
.kpi.orange .kpi-icon { background: rgba(255,159,10,.16); color: var(--warning); }
.kpi.purple .kpi-icon { background: rgba(59,56,56,.16); color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 12px;
    font-family: var(--font); font-weight: 700; font-size: 14px;
    border: 1px solid transparent; cursor: pointer;
    transition: .2s; background: var(--surface-2); color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; border-color: var(--border); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
    padding: 13px 14px; text-align: start;
    border-bottom: 1px solid var(--border); font-size: 14px;
}
table.data th { color: var(--text-muted); font-weight: 700; font-size: 13px; }
table.data tbody tr { transition: background .15s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; color: var(--text-muted); }
.field input, .field select, .field textarea {
    font-family: var(--font); font-size: 14px;
    padding: 11px 13px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); transition: .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,113,227,.15);
}
.field textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 16px; }
.checkbox { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 700;
}
.badge-at_tailor   { background: rgba(255,159,10,.16); color: #8a5600; }
.badge-ready       { background: rgba(52,199,89,.2); color: #1f6b32; }
.badge-in_showroom { background: rgba(0,113,227,.14); color: #0b3c79; }
.badge-delivered   { background: rgba(52,199,89,.2); color: #1f6b32; }
.badge-ok   { background: rgba(52,199,89,.2); color: #1f6b32; }
.badge-low  { background: rgba(255,159,10,.16); color: #8a5600; }
.badge-out  { background: rgba(255,59,48,.14); color: #b00020; }
.badge-paid { background: rgba(52,199,89,.2); color: #1f6b32; }
.badge-due  { background: rgba(255,159,10,.16); color: #8a5600; }
.badge-tailor-pending { background: rgba(255,159,10,.14); color: #8a5600; }
.badge-tailor-received_by_tailor { background: rgba(0,113,227,.14); color: #0b3c79; }
.badge-tailor-ready { background: rgba(52,199,89,.2); color: #1f6b32; }

/* ---------- Alerts ---------- */
.alert {
    padding: 13px 18px; border-radius: 12px;
    margin-bottom: 18px; font-weight: 600; font-size: 14px;
}
.alert-success { background: rgba(59,56,56,.12); color: var(--primary); }
.alert-error   { background: rgba(59,56,56,.18); color: var(--primary); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kanban-col {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px; min-height: 200px;
}
.kanban-col.drag-over { border-color: var(--primary); background: rgba(59,56,56,.08); }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kanban-col-title { font-weight: 700; font-size: 14px; }
.kanban-count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px; margin-bottom: 10px;
    cursor: grab; box-shadow: var(--shadow);
    transition: .2s;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .5; }
.kanban-card .kc-num { font-weight: 700; font-size: 13px; }
.kanban-card .kc-meta { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.kanban-card .kc-date.soon { color: var(--danger); font-weight: 700; }

/* ---------- Notifications ---------- */
.notif-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.notif-dot.warn { background: var(--warning); }
.notif-dot.danger { background: var(--danger); }
.notif-dot.info { background: var(--info); }
.notif-text { font-size: 14px; }
.notif-text small { color: var(--text-muted); display: block; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.text-success { color: var(--success); font-weight: 700; }
.text-danger { color: var(--danger); font-weight: 700; }
.empty { text-align: center; padding: 40px; color: var(--text-muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-input { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); min-width: 220px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tailor-actions { display: grid; gap: 12px; }
.btn-large { min-height: 52px; font-size: 18px; font-weight: 800; }

/* ---------- Auth ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #f0f0f0 0%, #3b3838 100%); }
.auth-card {
    background: var(--surface); border-radius: 24px;
    box-shadow: var(--shadow-lg); padding: 40px;
    width: 100%; max-width: 400px; margin: 20px;
}
.auth-logo { width: 60px; height: 60px; border-radius: 18px; background: var(--primary); color: #fff; font-weight: 800; font-size: 28px; display: grid; place-items: center; margin: 0 auto 18px; }
.auth-logo { overflow: hidden; }
.auth-logo img { width: 100%; height: 100%; object-fit: cover; }
.auth-card h2 { text-align: center; margin-bottom: 6px; }
.auth-card p.sub { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-inline-end: 0; margin-right: 0; }
    #menuToggle { display: grid; }
    .kanban { grid-template-columns: 1fr; }
    .user-name { display: none; }
    .content { padding: 18px; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin: 0 !important; }
    body { background: #fff; }
    .print-doc { box-shadow: none; border: none; }
}
