/* ============================================================
   StockTech UI — Glassmorphism theme (opt-in)
   Applied by: <body data-theme="glass">
   Scope: @media screen only — print / PDF / Excel are untouched
   ============================================================ */

@media screen {
  body[data-theme='glass'] {
    --g-panel: rgba(255, 255, 255, 0.06);
    --g-panel-2: rgba(255, 255, 255, 0.09);
    --g-border: rgba(148, 163, 184, 0.22);
    --g-border-strong: rgba(165, 180, 252, 0.4);
    --g-text: #eef2ff;
    --g-text-dim: rgba(203, 213, 225, 0.82);
    --g-glow: rgba(99, 102, 241, 0.9);
    --g-glow-2: rgba(14, 165, 233, 0.75);
    --g-blur: blur(18px) saturate(140%);

    --card: var(--g-panel);
    --text: var(--g-text);
    --text-light: var(--g-text-dim);
    --border: var(--g-border);

    background: radial-gradient(1400px circle at 8% -12%, rgba(99, 102, 241, 0.28), transparent 55%),
      radial-gradient(1200px circle at 95% 2%, rgba(14, 165, 233, 0.24), transparent 52%),
      radial-gradient(1600px circle at 50% 118%, rgba(56, 189, 248, 0.16), transparent 60%),
      linear-gradient(180deg, #020617 0%, #060a1c 60%, #04060f 100%);
    background-attachment: fixed;
    color: var(--g-text);
    min-height: 100vh;
  }

  /* ---------- Top navigation ---------- */
  body[data-theme='glass'] .topbar {
    background: radial-gradient(700px circle at 12% 50%, rgba(99, 102, 241, 0.26), transparent 70%),
      linear-gradient(180deg, rgba(2, 6, 23, 0.86), rgba(8, 13, 35, 0.9));
    backdrop-filter: var(--g-blur);
    -webkit-backdrop-filter: var(--g-blur);
    border-bottom: 1px solid var(--g-border);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 18px 60px -30px var(--g-glow);
  }

  body[data-theme='glass'] .brand {
    color: #f8fafc;
    text-shadow: 0 10px 60px rgba(129, 140, 248, 0.55);
  }

  body[data-theme='glass'] .brand .ico {
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.55), rgba(14, 165, 233, 0.3));
    border: 1px solid var(--g-border-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 26px -8px var(--g-glow);
  }

  body[data-theme='glass'] .nav a {
    color: rgba(226, 232, 255, 0.9);
  }

  body[data-theme='glass'] .nav a:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  body[data-theme='glass'] .nav a.active {
    background: rgba(99, 102, 241, 0.28);
    border-color: var(--g-border-strong);
    box-shadow: inset 0 -2px 0 rgba(165, 180, 252, 0.4), 0 12px 36px -18px var(--g-glow);
  }

  /* ---------- Page title ---------- */
  body[data-theme='glass'] .page-title {
    color: #f8fafc;
    text-shadow: 0 8px 50px rgba(129, 140, 248, 0.45);
  }

  /* ---------- Cards (frosted panels) ---------- */
  body[data-theme='glass'] .card {
    background: radial-gradient(700px circle at 95% -10%, rgba(99, 102, 241, 0.22), transparent 70%), var(--g-panel);
    backdrop-filter: var(--g-blur);
    -webkit-backdrop-filter: var(--g-blur);
    border: 1px solid var(--g-border);
    border-top-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 30px 90px -45px rgba(0, 0, 0, 0.9), 0 24px 80px -50px var(--g-glow);
    color: var(--g-text);
  }

  body[data-theme='glass'] .card:hover {
    box-shadow: 0 34px 100px -45px rgba(0, 0, 0, 0.95), 0 30px 90px -45px var(--g-glow);
  }

  body[data-theme='glass'] .card-title {
    color: #f8fafc;
  }

  /* ---------- Forms ---------- */
  body[data-theme='glass'] .form-group label {
    color: var(--g-text-dim);
  }

  body[data-theme='glass'] input[type='text'],
  body[data-theme='glass'] input[type='number'],
  body[data-theme='glass'] input[type='date'],
  body[data-theme='glass'] input[type='search'],
  body[data-theme='glass'] select,
  body[data-theme='glass'] textarea {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--g-border);
    color: var(--g-text);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  }

  body[data-theme='glass'] input::placeholder,
  body[data-theme='glass'] textarea::placeholder {
    color: rgba(203, 213, 225, 0.55);
  }

  body[data-theme='glass'] select option,
  body[data-theme='glass'] option {
    background: #0b1026;
    color: var(--g-text);
  }

  body[data-theme='glass'] input:focus,
  body[data-theme='glass'] select:focus,
  body[data-theme='glass'] textarea:focus {
    border-color: var(--g-border-strong);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(99, 102, 241, 0.28);
  }

  body[data-theme='glass'] input:disabled,
  body[data-theme='glass'] select:disabled,
  body[data-theme='glass'] textarea:disabled {
    background: rgba(255, 255, 255, 0.03);
    color: rgba(203, 213, 225, 0.5);
  }

  body[data-theme='glass'] .date-range-row .dash {
    color: var(--g-text-dim);
  }

  body[data-theme='glass'] .col-check input[type='checkbox'] {
    accent-color: #818cf8;
  }

  /* ---------- Buttons ---------- */
  body[data-theme='glass'] .btn-primary {
    background: linear-gradient(180deg, #6366f1, #4338ca);
    --btn-depth: #312e81;
    box-shadow: 0 6px 0 #312e81, 0 16px 50px -18px var(--g-glow);
  }

  body[data-theme='glass'] .btn-success {
    background: linear-gradient(180deg, #10b981, #047857);
    --btn-depth: #065f46;
  }

  body[data-theme='glass'] .btn-outline {
    background: rgba(255, 255, 255, 0.08);
    color: var(--g-text);
    border: 1px solid var(--g-border-strong);
    --btn-depth: rgba(129, 140, 248, 0.35);
    box-shadow: 0 4px 0 rgba(129, 140, 248, 0.3), 0 8px 24px -12px var(--g-glow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  body[data-theme='glass'] .btn-outline:hover {
    background: rgba(255, 255, 255, 0.14);
  }

  /* ---------- Tables ---------- */
  body[data-theme='glass'] .table-wrap {
    background: rgba(2, 6, 23, 0.35);
    border: 1px solid var(--g-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  }

  body[data-theme='glass'] table {
    color: var(--g-text);
  }

  body[data-theme='glass'] th,
  body[data-theme='glass'] td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  }

  body[data-theme='glass'] th {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.28), rgba(30, 41, 59, 0.55));
    color: #e9edff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  }

  body[data-theme='glass'] tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  body[data-theme='glass'] .total-row,
  body[data-theme='glass'] .total-row td {
    background: rgba(99, 102, 241, 0.18);
  }

  body[data-theme='glass'] .total-row td {
    border-top: 2px solid var(--g-border-strong);
  }

  body[data-theme='glass'] .stock-num {
    color: #f8fafc;
  }

  /* Report screen table (2-row header, 4 groups) */
  body[data-theme='glass'] #reportTableMain thead th {
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
    color: #e9edff;
    background: rgba(30, 41, 59, 0.5);
  }

  body[data-theme='glass'] #reportTableMain thead th.head-fixed {
    border-right: 1px solid rgba(148, 163, 184, 0.24);
  }

  body[data-theme='glass'] #reportTableMain thead th.group-head {
    color: #e9edff;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.3), rgba(37, 99, 235, 0.22));
    border-left: 1px solid rgba(148, 163, 184, 0.24);
    border-right: 1px solid rgba(148, 163, 184, 0.24);
  }

  body[data-theme='glass'] #reportTableMain thead th.sub-head {
    color: rgba(226, 232, 255, 0.86);
    background: rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(148, 163, 184, 0.14);
  }

  body[data-theme='glass'] #reportTableMain thead tr:first-child th {
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  }

  body[data-theme='glass'] #reportTableMain td.g-open,
  body[data-theme='glass'] #reportTableMain td.g-in,
  body[data-theme='glass'] #reportTableMain td.g-out,
  body[data-theme='glass'] #reportTableMain td.g-close {
    border-left: 1px solid rgba(148, 163, 184, 0.14);
  }

  body[data-theme='glass'] #reportTableMain td.g-close {
    background: rgba(99, 102, 241, 0.1);
    border-left: 1px solid rgba(148, 163, 184, 0.24);
  }

  body[data-theme='glass'] #reportTableMain .total-row td {
    background: rgba(99, 102, 241, 0.2);
  }

  body[data-theme='glass'] tr.row-low .col-check,
  body[data-theme='glass'] tr.row-low td {
    background: rgba(245, 158, 11, 0.14);
  }

  /* ---------- Badges ---------- */
  body[data-theme='glass'] .badge {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 14px -6px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  body[data-theme='glass'] .badge-in {
    background: rgba(16, 185, 129, 0.2);
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.45);
  }

  body[data-theme='glass'] .badge-out {
    background: rgba(248, 113, 113, 0.2);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.45);
  }

  body[data-theme='glass'] .badge-low {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.45);
  }

  body[data-theme='glass'] .badge-ok {
    background: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.4);
  }

  /* ---------- Alerts / toast ---------- */
  body[data-theme='glass'] .alert {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  body[data-theme='glass'] .alert-error {
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-left: 4px solid #f87171;
  }

  body[data-theme='glass'] .alert-success {
    background: rgba(16, 185, 129, 0.16);
    color: #a7f3d0;
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-left: 4px solid #34d399;
  }

  body[data-theme='glass'] .alert-info {
    background: rgba(59, 130, 246, 0.16);
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-left: 4px solid #60a5fa;
  }

  body[data-theme='glass'] .alert-warning {
    background: rgba(245, 158, 11, 0.16);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.42);
    border-left: 4px solid #fbbf24;
  }

  body[data-theme='glass'] .date-warn {
    color: #fcd34d;
  }

  body[data-theme='glass'] #toast {
    backdrop-filter: var(--g-blur);
    -webkit-backdrop-filter: var(--g-blur);
    border: 1px solid var(--g-border-strong);
    box-shadow: 0 24px 70px -24px var(--g-glow);
  }

  body[data-theme='glass'] .sel-hint {
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.45);
    color: #bfdbfe;
  }

  /* ---------- Modal ---------- */
  body[data-theme='glass'] .modal-backdrop {
    background: rgba(2, 6, 23, 0.62);
  }

  body[data-theme='glass'] .modal {
    background: radial-gradient(700px circle at 95% -10%, rgba(99, 102, 241, 0.22), transparent 70%),
      linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(8, 13, 35, 0.94));
    backdrop-filter: var(--g-blur);
    -webkit-backdrop-filter: var(--g-blur);
    border: 1px solid var(--g-border-strong);
    border-top-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 40px 120px -40px rgba(0, 0, 0, 1), 0 30px 90px -50px var(--g-glow);
    color: var(--g-text);
  }

  body[data-theme='glass'] .modal-title {
    color: #f8fafc;
  }

  body[data-theme='glass'] .modal-close {
    color: var(--g-text-dim);
  }

  body[data-theme='glass'] .modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
  }

  /* ---------- Empty / utilities ---------- */
  body[data-theme='glass'] .empty,
  body[data-theme='glass'] .muted {
    color: var(--g-text-dim);
  }

  /* ---------- Item picker ---------- */
  body[data-theme='glass'] .item-row {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--g-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  body[data-theme='glass'] .item-row:hover {
    border-color: var(--g-border-strong);
    background: rgba(255, 255, 255, 0.09);
  }

  body[data-theme='glass'] .item-row.selected {
    border-color: var(--g-border-strong);
    background: rgba(99, 102, 241, 0.22);
    box-shadow: inset 0 0 0 1px rgba(165, 180, 252, 0.4), 0 14px 40px -22px var(--g-glow);
  }

  body[data-theme='glass'] .item-row .item-meta,
  body[data-theme='glass'] .item-row .item-qty {
    color: var(--g-text);
  }

  body[data-theme='glass'] .item-row .item-meta {
    color: var(--g-text-dim);
  }

  body[data-theme='glass'] .selected-card {
    border: 1px dashed var(--g-border-strong);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.3);
  }

  /* ---------- Low-stock rows ---------- */
  body[data-theme='glass'] .low-item-row {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  body[data-theme='glass'] .low-item-row .meta {
    color: var(--g-text-dim);
  }

  /* ---------- Summary boxes ---------- */
  body[data-theme='glass'] .summary-box {
    background: radial-gradient(400px circle at 50% -20%, rgba(99, 102, 241, 0.22), transparent 70%), var(--g-panel);
    backdrop-filter: var(--g-blur);
    -webkit-backdrop-filter: var(--g-blur);
    border: 1px solid var(--g-border);
    border-top-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 20px 60px -34px rgba(0, 0, 0, 0.9), 0 18px 60px -40px var(--g-glow);
  }

  body[data-theme='glass'] .summary-box::before {
    background: linear-gradient(90deg, #818cf8, #38bdf8);
  }

  body[data-theme='glass'] .summary-box .label {
    color: var(--g-text-dim);
  }

  body[data-theme='glass'] .summary-box .value {
    color: #f8fafc;
  }

  /* ---------- Shortcut tiles ---------- */
  body[data-theme='glass'] .shortcut {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-top-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 0 rgba(2, 6, 23, 0.4), 0 20px 50px -24px var(--g-glow);
  }

  body[data-theme='glass'] .shortcut:hover {
    box-shadow: 0 10px 0 rgba(2, 6, 23, 0.36), 0 26px 60px -24px var(--g-glow);
  }

  /* ---------- Scrollbars (webkit) ---------- */
  body[data-theme='glass'] * {
    scrollbar-color: rgba(129, 140, 248, 0.6) rgba(255, 255, 255, 0.06);
  }

  body[data-theme='glass'] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  body[data-theme='glass'] ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
  }

  body[data-theme='glass'] ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(129, 140, 248, 0.7), rgba(56, 189, 248, 0.6));
    border-radius: 999px;
  }
}
