/* ==========================================================================
   AM Store — POS SAS Demo
   Hand-written design system. No build step, no external framework
   dependency — everything here is real CSS the browser understands
   natively, so nothing silently fails if a CDN is slow or blocked.
   ========================================================================== */

:root {
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-800: #3730a3;
    --primary-900: #312e81;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --success: #059669;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --info: #2563eb;
    --info-bg: #dbeafe;
    --info-text: #1e40af;

    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
    --shadow-lg: 0 25px 50px rgba(15, 23, 42, .25);
    --sidebar-w: 268px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { list-style: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---------------------------------------------------------------------- */
/* App shell: sidebar + main                                              */
/* ---------------------------------------------------------------------- */

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    right: 0;
    left: auto;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: #fff;
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--gray-100);
}
.sidebar-brand-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-400));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-text strong { display: block; font-size: 16px; font-weight: 800; color: var(--gray-900); }
.sidebar-brand-text span { font-size: 11px; color: var(--gray-400); font-weight: 600; letter-spacing: .04em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 14px; font-weight: 600;
    color: var(--gray-600);
    transition: background .15s, color .15s;
}
.sidebar-nav a i { width: 18px; text-align: center; color: var(--gray-400); transition: color .15s; font-size: 15px; }
.sidebar-nav a:hover { background: var(--gray-50); color: var(--gray-900); }
.sidebar-nav a.active { background: var(--primary-600); color: #fff; box-shadow: 0 4px 10px rgba(79, 70, 229, .25); }
.sidebar-nav a.active i { color: #fff; }

.sidebar-footer {
    padding: 16px; border-top: 1px solid var(--gray-100);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--primary-50); color: var(--primary-600);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { display: block; font-size: 13px; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info a { font-size: 12px; color: var(--danger); font-weight: 700; }
.sidebar-user-info a:hover { text-decoration: underline; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
    z-index: 45; backdrop-filter: blur(1px);
}

.main { margin-right: var(--sidebar-w); margin-left: 0; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    height: 68px; flex-shrink: 0;
    background: rgba(248, 250, 252, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    gap: 16px;
}
.sidebar-toggle {
    display: none; background: none; border: none; font-size: 20px;
    color: var(--gray-600); cursor: pointer; padding: 8px; border-radius: 10px;
}
.sidebar-toggle:hover { background: var(--gray-100); }
.topbar-title { font-size: 16px; font-weight: 800; color: var(--gray-900); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { font-size: 13px; color: var(--gray-500); font-weight: 600; }
.topbar-user i { color: var(--primary-500); margin-inline-end: 4px; }

.demo-banner {
    background: linear-gradient(90deg, #fffbeb, #fef3c7 50%, #fffbeb);
    border-bottom: 1px solid #fde68a;
    color: var(--warning-text);
    font-size: 13px;
    padding: 10px 20px;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
    text-align: center;
}
.demo-banner button {
    background: var(--warning-text); color: #fff; border: none; cursor: pointer;
    font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 6px;
}
.demo-banner button:hover { background: #78350f; }

.page { max-width: 1280px; margin: 0 auto; padding: 28px; width: 100%; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .main { margin-right: 0; }
    .sidebar-toggle { display: block; }
    .page { padding: 18px; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr !important; }
    .pos-grid { grid-template-columns: 1fr !important; }
}

/* ---------------------------------------------------------------------- */
/* Page header row                                                        */
/* ---------------------------------------------------------------------- */

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--gray-900); display: flex; align-items: center; gap: 10px; }
.page-header p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ---------------------------------------------------------------------- */
/* Stat cards                                                             */
/* ---------------------------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--gray-100); transition: box-shadow .15s, transform .15s; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }
.stat-tag { font-size: 11px; color: var(--gray-400); font-weight: 600; }
.stat-value { font-size: 25px; font-weight: 800; color: var(--gray-900); line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--gray-500); margin-top: 5px; }

/* ---------------------------------------------------------------------- */
/* Cards / tables                                                         */
/* ---------------------------------------------------------------------- */

.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--gray-100); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-header h2 { font-size: 15px; font-weight: 800; color: var(--gray-900); display: flex; align-items: center; gap: 8px; }
.card-header h2 i { color: var(--primary-500); }
.card-body { padding: 20px; }
.card-link { font-size: 13px; color: var(--primary-600); font-weight: 700; }
.card-link:hover { text-decoration: underline; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-main-side { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    text-align: start; padding: 12px 16px; font-size: 11.5px; font-weight: 800;
    color: var(--gray-500); text-transform: uppercase; letter-spacing: .03em;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-100); white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--gray-50); color: var(--gray-700); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--primary-50); }
.table-empty { text-align: center; color: var(--gray-400); padding: 44px 20px; }
.table-empty i { font-size: 24px; display: block; margin-bottom: 8px; }
.num { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }

/* ---------------------------------------------------------------------- */
/* Badges                                                                  */
/* ---------------------------------------------------------------------- */

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 22px; border-radius: 12px; font-size: 14px; font-weight: 700;
    border: none; cursor: pointer; transition: background .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary-600); color: #fff; box-shadow: 0 2px 8px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-700); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger-bg); color: var(--danger-text); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 7px 16px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon {
    width: 34px; height: 34px; padding: 0; border-radius: 10px;
    background: transparent; color: var(--gray-500); font-size: 13px;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger-text); }
.btn-icon.primary:hover { background: var(--primary-50); color: var(--primary-600); }
.btn-icon.amber:hover { background: var(--warning-bg); color: var(--warning-text); }
.icon-link { font-size: 13px; color: var(--primary-600); font-weight: 700; background: none; border: none; cursor: pointer; }
.icon-link:hover { color: var(--primary-700); }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.form-input, .form-select, textarea.form-input {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: 12px;
    font-size: 14px; font-family: inherit; outline: none; background: #fff; color: var(--gray-800);
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px var(--primary-100); }
textarea.form-input { resize: vertical; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; padding-top: 6px; }
.form-actions .btn { flex: 1; }

.search-box { position: relative; }
.search-box i { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.search-box input { padding-inline-start: 40px; }

/* ---------------------------------------------------------------------- */
/* Modal                                                                   */
/* ---------------------------------------------------------------------- */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px);
    z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; border-radius: 22px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; padding: 28px;
    animation: modalIn .18s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h3 { font-size: 18px; font-weight: 800; color: var(--gray-900); }
.modal-close { background: none; border: none; color: var(--gray-400); font-size: 20px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--gray-700); }
@keyframes modalIn { from { opacity: 0; transform: translateY(-14px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------- */
/* Alerts / toasts                                                         */
/* ---------------------------------------------------------------------- */

#alert-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw);
}
.alert {
    padding: 13px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-md);
    animation: fadeIn .2s ease;
}
.alert-success { background: #ecfdf5; color: var(--success-text); border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: var(--danger-text); border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: var(--info-text); border: 1px solid #bfdbfe; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.alert-static { margin-bottom: 16px; }

/* ---------------------------------------------------------------------- */
/* POS screen                                                              */
/* ---------------------------------------------------------------------- */

.pos-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; max-height: 460px; overflow-y: auto; padding: 4px; }
.product-tile { background: #fff; border: 1.5px solid var(--gray-200); border-radius: 14px; padding: 14px 10px; cursor: pointer; text-align: center; transition: border-color .15s, box-shadow .15s, transform .1s; }
.product-tile:hover { border-color: var(--primary-400); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.product-tile.flash { border-color: var(--primary-500); background: var(--primary-50); }
.product-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-50); color: var(--primary-600); display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; font-size: 15px; }
.product-icon.amber { background: var(--warning-bg); color: var(--warning-text); }
.product-name { font-size: 12.5px; font-weight: 700; color: var(--gray-800); line-height: 1.3; margin-bottom: 3px; }
.product-price { font-size: 11.5px; color: var(--gray-500); }
.product-stock { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.product-stock.low { color: var(--danger); }

.cart-list { min-height: 180px; max-height: 300px; overflow-y: auto; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.cart-empty { text-align: center; color: var(--gray-400); padding: 36px 0; }
.cart-empty i { font-size: 26px; display: block; margin-bottom: 8px; }
.cart-row { display: flex; align-items: center; justify-content: space-between; background: var(--gray-50); border-radius: 12px; padding: 10px 12px; gap: 10px; }
.cart-row-info p:first-child { font-size: 13.5px; font-weight: 700; color: var(--gray-900); }
.cart-row-info p:last-child { font-size: 12px; color: var(--gray-500); }
.qty-btn { width: 26px; height: 26px; border-radius: 8px; background: var(--gray-200); border: none; cursor: pointer; font-weight: 800; color: var(--gray-700); }
.qty-btn:hover { background: var(--gray-300); }
.cart-remove { width: 26px; height: 26px; border-radius: 8px; background: var(--danger-bg); color: var(--danger-text); border: none; cursor: pointer; }
.cart-total-row { border-top: 1px solid var(--gray-100); padding-top: 14px; display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 800; }
.cart-total-row span:last-child { color: var(--primary-600); }

/* ---------------------------------------------------------------------- */
/* Login / auth page                                                       */
/* ---------------------------------------------------------------------- */

.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(circle at 20% 20%, #312e81, transparent 60%),
                radial-gradient(circle at 80% 80%, #4338ca, transparent 60%),
                linear-gradient(135deg, #1e1b4b, #312e81 50%, #4338ca);
    position: relative; overflow: hidden;
}
.auth-decor { position: absolute; inset: 0; opacity: .08; pointer-events: none; color: #fff; }
.auth-decor i { position: absolute; }
.auth-card {
    background: rgba(255, 255, 255, .97); border-radius: 26px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 440px; padding: 36px; position: relative; z-index: 1;
}
.auth-logo { width: 66px; height: 66px; border-radius: 18px; background: var(--primary-50); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.auth-logo i { font-size: 26px; color: var(--primary-600); }
.auth-card h1 { text-align: center; font-size: 22px; font-weight: 800; color: var(--gray-900); }
.auth-card > p.subtitle { text-align: center; color: var(--gray-500); margin-top: 4px; margin-bottom: 22px; font-size: 13.5px; }
.auth-demo-box { background: var(--primary-50); border: 1px solid var(--primary-100); border-radius: 14px; padding: 14px 16px; margin-bottom: 20px; font-size: 13px; }
.auth-demo-box p:first-child { color: var(--primary-700); font-weight: 700; margin-bottom: 4px; }
.auth-demo-box p:last-child { color: var(--gray-500); font-size: 12.5px; }
.auth-demo-box code { font-family: 'Cairo', monospace; background: rgba(255,255,255,.6); padding: 1px 6px; border-radius: 6px; }
.auth-input-wrap { position: relative; }
.auth-input-wrap i { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.auth-input-wrap input { padding-inline-start: 40px; }
.auth-footer-note { text-align: center; margin-top: 20px; font-size: 11.5px; color: var(--gray-400); }

/* ---------------------------------------------------------------------- */
/* Misc                                                                    */
/* ---------------------------------------------------------------------- */

.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid var(--gray-200); border-top-color: var(--primary-500); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--gray-500); }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
