/* =============================================================
   Stock Manager Pro — Premium Glassmorphism UI
   Palette: primary teal-blue, slate neutrals, amber accent.
   ============================================================= */

:root {
    --primary: #0ea5a4;          /* teal */
    --primary-dark: #0b7f7e;
    --primary-soft: rgba(14, 165, 164, 0.12);
    --accent: #f59e0b;           /* amber accent */
    --danger: #ef4444;
    --success: #16a34a;
    --warning: #f59e0b;
    --info: #0284c7;

    --bg: #eef2f6;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #d9f2f1 0%, transparent 60%),
               radial-gradient(1000px 500px at 110% 10%, #dbeafe 0%, transparent 55%),
               #eef2f6;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-solid: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 8px 30px rgba(2, 32, 71, 0.08);
    --radius: 16px;
    --sidebar-w: 260px;
}

[data-bs-theme="dark"] {
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --primary-soft: rgba(45, 212, 191, 0.14);
    --bg: #0b1220;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #0e2a2a 0%, transparent 60%),
               radial-gradient(1000px 500px at 110% 10%, #10233f 0%, transparent 55%),
               #0b1220;
    --surface: rgba(23, 33, 51, 0.72);
    --surface-solid: #121a2b;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

.glass {
    background: var(--surface);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    transition: margin .25s ease;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px 18px;
    font-weight: 700; font-size: 1.1rem;
}
.brand-mark {
    display: grid; place-items: center;
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; font-size: 1.2rem;
}
.sidebar-nav { flex: 1; overflow-y: auto; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted);
    padding: 11px 14px; margin-bottom: 4px;
    border-radius: 12px; font-weight: 500;
    transition: all .18s ease;
}
.sidebar-nav .nav-link i { font-size: 1.15rem; width: 22px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; box-shadow: 0 6px 16px var(--primary-soft);
}
.sidebar-footer { padding-top: 10px; border-top: 1px solid var(--border); }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 1035;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 16px;
    padding: 12px 20px;
    border-left: 0; border-right: 0; border-top: 0;
}
.topbar-title { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-icon {
    display: grid; place-items: center;
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--surface-solid); border: 1px solid var(--border);
    color: var(--text); font-size: 1.15rem;
}
.btn-icon:hover { color: var(--primary); }
.user-chip {
    display: flex; align-items: center; text-align: left;
    background: var(--surface-solid); border: 1px solid var(--border);
    border-radius: 12px; padding: 6px 12px; color: var(--text);
}
.avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; font-weight: 700;
}
.theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: inline; }

/* ---------- Page content ---------- */
.page-content { padding: 22px; flex: 1; }
.app-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 22px; color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.dev-credit { font-size: .72rem; letter-spacing: 2px; opacity: .7; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; }

/* Stat cards */
.stat-card { padding: 18px; display: flex; align-items: center; gap: 16px; }
.stat-icon {
    display: grid; place-items: center;
    width: 54px; height: 54px; border-radius: 14px;
    font-size: 1.5rem; color: #fff; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--text-muted); font-size: .85rem; }
.bg-grad-primary { background: linear-gradient(135deg, #0ea5a4, #0b7f7e); }
.bg-grad-blue    { background: linear-gradient(135deg, #0284c7, #0369a1); }
.bg-grad-amber   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-grad-green   { background: linear-gradient(135deg, #16a34a, #15803d); }
.bg-grad-red     { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.bg-grad-slate   { background: linear-gradient(135deg, #475569, #334155); }
.bg-grad-indigo  { background: linear-gradient(135deg, #6366f1, #4338ca); }

/* ---------- Product live-search dropdown ---------- */
.search-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
    background: var(--surface-solid); border: 1px solid var(--border);
    border-radius: 12px; margin-top: 4px; max-height: 320px; overflow-y: auto;
    box-shadow: 0 12px 30px rgba(0,0,0,.14);
}
.search-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; text-align: left; padding: 10px 14px; border: none;
    background: transparent; color: var(--text); border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-outline-primary { color: var(--primary-dark); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

/* ---------- Tables ---------- */
.table { color: var(--text); vertical-align: middle; }
.table > :not(caption) > * > * { background: transparent; }
.table thead th {
    color: var(--text-muted); text-transform: uppercase;
    font-size: .72rem; letter-spacing: .5px; border-bottom: 2px solid var(--border);
}
.table-hover tbody tr:hover { background: var(--primary-soft); }

/* ---------- Forms ---------- */
.form-control, .form-select {
    background: var(--surface-solid); border: 1px solid var(--border); color: var(--text);
}
.form-control:focus, .form-select:focus {
    background: var(--surface-solid); color: var(--text);
    border-color: var(--primary); box-shadow: 0 0 0 .2rem var(--primary-soft);
}
.form-label { font-weight: 500; font-size: .9rem; }

/* ---------- Badges ---------- */
.badge-soft-success { background: rgba(22,163,74,.15); color: #16a34a; }
.badge-soft-warning { background: rgba(245,158,11,.18); color: #b45309; }
.badge-soft-danger  { background: rgba(239,68,68,.15); color: #dc2626; }
.badge-soft-info    { background: rgba(2,132,199,.15); color: #0284c7; }

/* ---------- Loader ---------- */
.app-loader {
    position: fixed; inset: 0; display: none; place-items: center;
    background: rgba(2, 20, 40, .35); z-index: 2000;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.app-loader.show { display: grid; }
.spinner-ring {
    width: 46px; height: 46px; border-radius: 50%;
    border: 4px solid rgba(255,255,255,.35); border-top-color: #fff;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Animations ---------- */
.fade-in { animation: fadeIn .4s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: var(--bg-grad); background-attachment: fixed;
}
.login-card { width: 100%; max-width: 410px; padding: 34px; border-radius: 22px; }
.login-logo {
    width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px;
    display: grid; place-items: center; font-size: 1.7rem; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-sidebar.open ~ .sidebar-backdrop { display: block; }
}

/* ---------- Invoice / Receipt ---------- */
.invoice-page { background: #eef1f5; padding: 30px 15px; }
.invoice-sheet {
    max-width: 800px; margin: 0 auto; background: #fff; color: #1e293b;
    padding: 40px; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.invoice-sheet .text-primary { color: var(--primary-dark) !important; }
.sign-line { border-top: 1px solid #94a3b8; padding-top: 6px; min-width: 160px; color: #64748b; font-size: .85rem; }
.invoice-actions { max-width: 800px; margin: 20px auto 0; display: flex; gap: 10px; justify-content: center; }

/* ---------- Print ---------- */
@media print {
    .app-sidebar, .topbar, .app-footer, .no-print, .sidebar-backdrop { display: none !important; }
    .app-main { margin-left: 0 !important; }
    body { background: #fff !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; background: #fff !important; }
    .invoice-page { background: #fff !important; padding: 0 !important; }
    .invoice-sheet { box-shadow: none !important; border-radius: 0 !important; padding: 0 !important; max-width: 100% !important; }
}
