/* FILE: css/premium.css — premium polish + live-form styles (loaded last) */
:root {
  --pm-ring: 0 0 0 4px rgba(20, 184, 166, .16);
  --pm-ease: cubic-bezier(.16, 1, .3, 1);
  --pm-shadow-sm: 0 1px 2px rgba(11, 27, 58, .05), 0 1px 1px rgba(11, 27, 58, .03);
  --pm-shadow-md: 0 10px 30px -14px rgba(11, 27, 58, .22), 0 2px 6px -2px rgba(11, 27, 58, .06);
  --pm-shadow-lg: 0 30px 80px -24px rgba(11, 27, 58, .45);
}

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: rgba(20, 184, 166, .28); }
body {
  background-image:
    radial-gradient(900px 420px at 100% -10%, rgba(20, 184, 166, .07), transparent 60%),
    radial-gradient(700px 380px at -10% 0%, rgba(245, 166, 35, .05), transparent 60%);
  background-attachment: fixed;
}
html.dark body { background-image: radial-gradient(900px 420px at 100% -10%, rgba(20, 184, 166, .09), transparent 60%); }

/* ---------- Cards & tables ---------- */
.stats-card, .card-hover, .bg-white.rounded-xl.border, .bg-white.rounded-2xl.border {
  border-radius: 18px;
  box-shadow: var(--pm-shadow-sm);
}
.card-hover:hover { box-shadow: var(--pm-shadow-md); }
table thead th { letter-spacing: .06em; font-size: 10.5px !important; font-weight: 600 !important; }
table tbody tr { transition: background-color .18s ease; }
table tbody tr:hover { background: rgba(20, 184, 166, .05); }
html.dark table tbody tr:hover { background: rgba(94, 234, 212, .06); }
table td, table th { padding-top: .8rem; padding-bottom: .8rem; }

/* ---------- Top bar / sidebar ---------- */
#topbar-root header { backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); }
#sidebar-root aside {
  background-image: linear-gradient(180deg, rgba(20, 184, 166, .10), transparent 240px), linear-gradient(180deg, #0B1B3A, #0A1730);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .05);
}

/* ---------- Inputs ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
select, textarea {
  border-radius: 12px !important;
  transition: border-color .18s ease, box-shadow .22s var(--pm-ease), background-color .18s ease;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):hover,
select:hover, textarea:hover { border-color: #94a3b8; }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  outline: none !important; border-color: #14b8a6 !important; box-shadow: var(--pm-ring) !important;
}
select:not([multiple]) {
  -webkit-appearance: none; appearance: none; padding-right: 2.25rem !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center;
}
input:user-valid:not(:placeholder-shown):not([type=checkbox]):not([type=radio]):not([type=date]) { border-color: #34d399; }
label.block { letter-spacing: .005em; }

/* ---------- Buttons ---------- */
button.bg-brand-600, a.bg-brand-600 {
  background-image: linear-gradient(135deg, #14b8a6 0%, #0d9488 55%, #0f766e 100%) !important;
  box-shadow: 0 8px 20px -8px rgba(13, 148, 136, .65), inset 0 1px 0 rgba(255, 255, 255, .22);
  position: relative; overflow: hidden; border-radius: 12px !important;
  transition: transform .18s var(--pm-ease), box-shadow .2s ease, filter .2s ease;
}
button.bg-brand-600::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  transition: transform .7s var(--pm-ease);
}
button.bg-brand-600:hover::after { transform: translateX(120%); }
button.bg-brand-600:hover { filter: saturate(1.08); box-shadow: 0 14px 28px -10px rgba(13, 148, 136, .7), inset 0 1px 0 rgba(255, 255, 255, .25); }
button.bg-brand-600:active { transform: scale(.975); }
button.bg-brand-600:disabled { filter: grayscale(.4); opacity: .65; }

/* ---------- Radio / choice cards ---------- */
label:has(> input[type=radio]) {
  border-radius: 12px !important;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .22s var(--pm-ease), transform .15s ease;
}
label:has(> input[type=radio]:checked) { box-shadow: 0 0 0 3px rgba(20, 184, 166, .14); font-weight: 600; }
label:has(> input[type=radio][value=udhar]:checked) { box-shadow: 0 0 0 3px rgba(245, 158, 11, .16); }
label:has(> input[type=radio]):active { transform: scale(.97); }

/* ---------- Modals ---------- */
.app-modal { background: rgba(8, 17, 38, .55) !important; backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2); }
html body .app-modal .modal-panel {
  border-radius: 26px 26px 0 0;
  box-shadow: var(--pm-shadow-lg);
  border: 1px solid rgba(255, 255, 255, .6);
  transition: transform .42s var(--pm-ease), opacity .3s ease;
}
@media (min-width: 640px) { html body .app-modal .modal-panel { border-radius: 26px; } }
html.dark body .app-modal .modal-panel { border-color: rgba(255, 255, 255, .07); }
.app-modal .modal-panel > div:first-child {
  background: linear-gradient(180deg, rgba(240, 253, 250, .95), rgba(255, 255, 255, .95)) !important;
  border-bottom-color: rgba(20, 184, 166, .15) !important; backdrop-filter: blur(10px);
}
html.dark .app-modal .modal-panel > div:first-child { background: linear-gradient(180deg, #16223a, #131b2c) !important; border-bottom-color: #22304a !important; }
.app-modal .modal-panel > div:first-child h3 { font-family: "Fraunces", serif; font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em; }
.app-modal [data-close-modal].text-xl, .app-modal .modal-panel > div:first-child > button[aria-label] {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
  background: rgba(100, 116, 139, .1); font-size: 1.35rem; transition: background .18s, transform .2s var(--pm-ease);
}
.app-modal .modal-panel > div:first-child > button[aria-label]:hover { background: rgba(244, 63, 94, .12); color: #e11d48; transform: rotate(90deg); }
@media (max-width: 639px) {
  .app-modal .modal-panel > div:first-child::before {
    content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px;
    border-radius: 4px; background: rgba(100, 116, 139, .35);
  }
}
/* fields rise in one after another */
.app-modal.modal-open form > div, .app-modal.modal-open form > .grid { animation: pmRise .5s var(--pm-ease) both; }
.app-modal.modal-open form > *:nth-child(1) { animation-delay: .04s; } .app-modal.modal-open form > *:nth-child(2) { animation-delay: .08s; }
.app-modal.modal-open form > *:nth-child(3) { animation-delay: .12s; } .app-modal.modal-open form > *:nth-child(4) { animation-delay: .16s; }
.app-modal.modal-open form > *:nth-child(5) { animation-delay: .2s; } .app-modal.modal-open form > *:nth-child(n+6) { animation-delay: .24s; }
@keyframes pmRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Sticky action bar: frosted */
.form-actions { background: rgba(255, 255, 255, .88) !important; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
html.dark .form-actions { background: rgba(19, 27, 44, .9) !important; }

/* Existing preview boxes get a richer surface */
#sale-preview, #product-preview {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9) !important; border: 1px solid #e2e8f0; border-radius: 16px !important;
}
html.dark #sale-preview, html.dark #product-preview { background: rgba(255, 255, 255, .03) !important; border-color: #22304a; }

/* ================= Live insight card ================= */
.lf-card {
  position: relative; border-radius: 18px; padding: .9rem 1rem 1rem; overflow: hidden;
  background: linear-gradient(160deg, rgba(240, 253, 250, .9), rgba(255, 255, 255, .95) 60%);
  border: 1px solid rgba(20, 184, 166, .28);
  box-shadow: 0 10px 28px -18px rgba(13, 148, 136, .55);
  display: grid; gap: .65rem;
}
.lf-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, #14b8a6, #f5a623, #14b8a6); background-size: 200% 100%; animation: pmSlide 6s linear infinite; }
html.dark .lf-card { background: linear-gradient(160deg, rgba(20, 184, 166, .10), rgba(19, 27, 44, .9) 65%); border-color: rgba(94, 234, 212, .22); box-shadow: none; }
.lf-pop { animation: lfPop .35s var(--pm-ease); }
@keyframes lfPop { from { transform: scale(.985); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pmSlide { to { background-position: -200% 0; } }

.lf-head { display: flex; align-items: center; gap: .5rem; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #0f766e; }
html.dark .lf-head { color: #5eead4; }
.lf-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); animation: lfPulse 1.8s infinite; }
@keyframes lfPulse { 70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
.lf-empty { font-size: 12.5px; color: #64748b; text-align: center; padding: .25rem 0; }

.lf-prices, .lf-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.lf-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .65rem; border-radius: 999px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; background: rgba(100, 116, 139, .1); color: #475569; }
.lf-chip i { font-style: normal; font-size: 9px; }
.lf-chip.ok { background: #ecfdf5; color: #047857; } .lf-chip.warn { background: #fffbeb; color: #b45309; }
.lf-chip.bad { background: #fff1f2; color: #be123c; } .lf-chip.on { background: #0d9488; color: #fff; box-shadow: 0 6px 14px -6px rgba(13, 148, 136, .8); }
html.dark .lf-chip { background: rgba(255, 255, 255, .07); color: #cbd5e1; }
html.dark .lf-chip.ok { background: rgba(16, 185, 129, .16); color: #6ee7b7; } html.dark .lf-chip.warn { background: rgba(245, 158, 11, .16); color: #fcd34d; }
html.dark .lf-chip.bad { background: rgba(244, 63, 94, .16); color: #fda4af; } html.dark .lf-chip.on { background: #0d9488; color: #fff; }

.lf-gauge { display: grid; gap: .5rem; }
.lf-gauge-bar { position: relative; height: 8px; border-radius: 99px; background: rgba(100, 116, 139, .16); overflow: hidden; }
.lf-gauge-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; transition: width .45s var(--pm-ease), background-color .3s; }
.lf-gauge-bar i.ok { background: linear-gradient(90deg, #34d399, #10b981); } .lf-gauge-bar i.warn { background: linear-gradient(90deg, #fcd34d, #f59e0b); } .lf-gauge-bar i.bad { background: linear-gradient(90deg, #fb7185, #e11d48); }
.lf-gauge-bar s { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(11, 27, 58, .45); }

.lf-flow, .lf-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; font-size: 13px; color: #64748b; }
.lf-flow-v { display: inline-flex; align-items: center; gap: .45rem; font-variant-numeric: tabular-nums; }
.lf-flow-v em { font-style: normal; color: #94a3b8; text-decoration: line-through; text-decoration-color: rgba(148, 163, 184, .6); }
.lf-flow-v b, .lf-row b { color: #0f172a; font-weight: 700; }
html.dark .lf-flow-v b, html.dark .lf-row b { color: #f1f5f9; }
.lf-card b.ok { color: #059669; } .lf-card b.warn { color: #d97706; } .lf-card b.bad { color: #e11d48; }
.lf-note { font-size: 12.5px; line-height: 1.4; color: #b45309; background: #fffbeb; border-radius: 12px; padding: .5rem .75rem; }
.lf-note.bad { color: #be123c; background: #fff1f2; }
html.dark .lf-note { background: rgba(245, 158, 11, .12); color: #fcd34d; } html.dark .lf-note.bad { background: rgba(244, 63, 94, .12); color: #fda4af; }

.lf-quick { display: flex; flex-wrap: wrap; gap: .4rem; }
.lf-quick button {
  padding: .4rem .8rem; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: #fff; color: #0f766e; border: 1px solid rgba(20, 184, 166, .35);
  transition: transform .15s var(--pm-ease), background .15s, color .15s;
}
.lf-quick button:hover { background: #0d9488; color: #fff; } .lf-quick button:active { transform: scale(.93); }
html.dark .lf-quick button { background: rgba(255, 255, 255, .04); color: #5eead4; }

.lf-echo { height: 0; overflow: hidden; opacity: 0; font-size: 11.5px; font-weight: 600; color: #0d9488; font-variant-numeric: tabular-nums; transition: height .2s ease, opacity .2s ease, margin .2s ease; }
.lf-echo.on { height: 1.1rem; opacity: 1; margin-top: .3rem; }
html.dark .lf-echo { color: #5eead4; }

/* ================= Real-time flash & connection pill ================= */
.live-flash { animation: liveFlash 1.2s ease-out; border-radius: 6px; }
@keyframes liveFlash {
  0% { background: rgba(20, 184, 166, .35); box-shadow: 0 0 0 4px rgba(20, 184, 166, .25); }
  100% { background: transparent; box-shadow: 0 0 0 4px transparent; }
}
.conn-pill {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 120; transform: translate(-50%, -140%);
  display: inline-flex; align-items: center; gap: .55rem; padding: .55rem 1rem; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: #fff;
  box-shadow: var(--pm-shadow-md); transition: transform .45s var(--pm-ease); max-width: 92vw;
}
.conn-pill.show { transform: translate(-50%, 0); }
.conn-pill.off { background: #b45309; } .conn-pill.on { background: #047857; }
.conn-pill i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: lfPulse 1.6s infinite; }

@media (prefers-reduced-motion: reduce) {
  .lf-card::before, .lf-dot, .conn-pill i, .app-modal.modal-open form > * { animation: none !important; }
  .live-flash { animation-duration: .01s; }
}
