/*
  Vib Writer AI - v1.0.2 Design Refresh
  Scope: UI/UX only. Existing features, form field names, API flow and backend logic remain preserved.
*/

/* 01. Design Tokens */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --ink: #111827;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5e7eb;
  --brand: #6356f1;
  --brand-dark: #4f46e5;
  --brand-2: #8b5cf6;
  --accent: #06b6d4;
  --success: #047857;
  --success-bg: #ecfdf5;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --warning: #f59e0b;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --shadow-card: 0 12px 35px rgba(15, 23, 42, .08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, .06);
  --ring: 0 0 0 4px rgba(99, 86, 241, .14);
  --font-ui: Inter, "Noto Sans Bengali", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* 02. Base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at 15% -10%, rgba(99, 86, 241, .16), transparent 30%),
    radial-gradient(circle at 96% 8%, rgba(6, 182, 212, .12), transparent 26%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.muted-link { color: var(--brand-dark); font-weight: 800; display: inline-flex; margin-top: 16px; }

/* 03. App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 250, 252, .86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, .85);
}
.app-header-inner {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  font-weight: 950;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 24px rgba(99, 86, 241, .22);
}
.brand-copy { display: grid; gap: 2px; line-height: 1.05; }
.brand-copy strong { font-size: 17px; letter-spacing: -.02em; }
.brand-copy small { font-size: 12px; color: var(--muted); font-weight: 700; }
.header-actions { display: inline-flex; align-items: center; gap: 10px; }
.status-chip,
.icon-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  padding: 0 12px;
}
.icon-link { width: 38px; padding: 0; color: var(--ink); }

/* 04. Layout */
.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}
.intro-card {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 16px;
  padding: 22px;
  border: 1px solid rgba(226, 232, 240, .86);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-soft);
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(30px, 4.2vw, 56px);
  line-height: .98;
  letter-spacing: -.055em;
}
h1 span { color: var(--brand); }
.intro-card p:last-child {
  margin: 12px 0 0;
  max-width: 650px;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.65;
}
.intro-flow {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.intro-flow b { color: var(--brand); }
.quick-presets {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin: 0 0 18px;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}
.preset-chip {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .04);
}
.preset-chip:hover,
.preset-chip.active {
  border-color: rgba(99, 86, 241, .32);
  background: #eef2ff;
  color: var(--brand-dark);
}
.main-grid {
  display: grid;
  grid-template-columns: minmax(420px, .92fr) minmax(520px, 1.08fr);
  gap: 24px;
  align-items: start;
}
.card {
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-card);
}
.generator-card,
.output-card { padding: 24px; }
.output-card {
  position: sticky;
  top: 94px;
  max-height: calc(100vh - 116px);
  overflow: auto;
}
.section-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 20px;
}
.section-title.no-margin { margin: 0; }
.section-title > span {
  flex: 0 0 auto;
  min-width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #eef2ff;
  color: var(--brand-dark);
  font-weight: 950;
  font-size: 13px;
}
.section-title h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* 05. Forms */
.writer-form { display: grid; gap: 15px; }
.form-hint {
  margin: -6px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid #e0e7ff;
  background: #f5f7ff;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.writer-form label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 900;
}
.writer-form small {
  justify-self: end;
  margin-top: -4px;
  color: var(--muted-2);
  font-size: 12px;
}
.writer-form input,
.writer-form select,
.writer-form textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.writer-form textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.65;
}
.writer-form input:focus,
.writer-form select:focus,
.writer-form textarea:focus {
  border-color: rgba(99, 86, 241, .58);
  box-shadow: var(--ring);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  font-weight: 950;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 14px 28px rgba(99, 86, 241, .24);
}
.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
}
.btn.full { width: 100%; }
.btn[disabled],
.mini-copy[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* 06. Alerts and Loading */
.alert {
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
}
.alert.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert.success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.inline-retry {
  margin-left: 8px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  font-weight: 950;
  padding: 7px 11px;
}
.processing-card {
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid #ddd6fe;
  background: linear-gradient(180deg, #ffffff, #f8f7ff);
}
.spark-orb {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 14px 30px rgba(99, 86, 241, .28);
  animation: pulseOrb 1.5s ease-in-out infinite;
}
.processing-card h3 { margin: 0; font-size: 17px; }
.processing-card p { margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.progress {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e0e7ff;
}
.progress span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width .35s ease;
}
.skeleton-lines { display: grid; gap: 8px; margin-top: 13px; }
.skeleton-lines i {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef2ff, #e0e7ff, #eef2ff);
  background-size: 240% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-lines i:nth-child(2) { width: 76%; }
.skeleton-lines i:nth-child(3) { width: 52%; }
@keyframes pulseOrb { 50% { transform: scale(1.04); box-shadow: 0 18px 36px rgba(99, 86, 241, .34); } }
@keyframes shimmer { to { background-position: -240% 0; } }

/* 07. Results */
.output-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.result-content { display: grid; gap: 14px; }
.result-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 16px;
}
.result-section h3 {
  margin: 0 0 11px;
  font-size: 15px;
  letter-spacing: -.01em;
}
.section-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.section-copy h3 { margin: 0; }
.mini-copy {
  min-height: 32px;
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  background: #f5f3ff;
  color: var(--brand-dark);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 950;
}
.result-box {
  white-space: normal;
  word-break: break-word;
  line-height: 1.82;
  color: #1f2937;
  font-size: 15.8px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  padding: 15px;
}
.tag-wrap { display: flex; flex-wrap: wrap; gap: 9px; }
.tag-wrap span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--brand-dark);
  border: 1px solid #dbeafe;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 900;
}
.tips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}
.tips li {
  position: relative;
  padding-left: 24px;
  color: var(--muted);
  line-height: 1.62;
  font-size: 14px;
}
.tips li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: .05em;
  color: var(--brand-dark);
  font-weight: 950;
}
.mini-note {
  margin: -3px 0 11px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 760;
}
.quality-score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: #ecfeff;
  color: #155e75;
  border: 1px solid #cffafe;
  font-weight: 950;
}
.empty-state {
  min-height: 430px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fff, #f8fafc);
  padding: 30px;
}
.empty-icon {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 50%;
  color: #fff;
  font-size: 34px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 16px 30px rgba(99, 86, 241, .22);
}
.empty-state h3 { margin: 0; color: var(--ink); font-size: 18px; }
.empty-state p { margin: 0; max-width: 420px; line-height: 1.65; font-size: 14px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 100;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #0f172a;
  color: #fff;
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 18px 36px rgba(15, 23, 42, .2);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 08. Mobile Bottom Navigation */
.bottom-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
  padding: 8px;
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 24px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .14);
}
.bottom-nav a {
  flex: 1;
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}
.bottom-nav a:hover { background: #eef2ff; color: var(--brand-dark); }

/* 09. Admin */
.center-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}
.login-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-card);
  padding: 28px;
}
.login-card h1 { font-size: 28px; line-height: 1.1; margin-bottom: 18px; }
.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
  background: var(--bg);
}
.admin-layout aside {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fff;
}
.admin-layout aside h2 {
  margin: 0 0 22px;
  font-size: 22px;
  letter-spacing: -.03em;
}
.admin-layout aside a {
  min-height: 44px;
  display: flex;
  align-items: center;
  margin: 7px 0;
  padding: 0 13px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 900;
}
.admin-layout aside a:hover,
.admin-layout aside a.active { background: #eef2ff; color: var(--brand-dark); }
.admin-layout main { padding: 26px; overflow: auto; }
.admin-layout main > h1 { font-size: clamp(28px, 3vw, 42px); margin: 0 0 18px; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 20px;
}
.stat-grid b { display: block; font-size: 34px; line-height: 1; color: var(--brand-dark); }
.stat-grid span { display: block; margin-top: 8px; color: var(--muted); font-weight: 850; }
.table-wrap { overflow: auto; border-radius: var(--radius-md); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
th { background: #f8fafc; color: var(--muted); font-weight: 950; }
td { color: #334155; }
.admin-layout .card { padding: 20px; }
.admin-layout textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* 10. Responsive */
@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
  .output-card { position: static; max-height: none; }
  .intro-card { align-items: start; flex-direction: column; }
}
@media (max-width: 880px) {
  .app-shell { width: min(100% - 28px, 640px); padding-bottom: 114px; }
  .app-header-inner { width: calc(100% - 28px); min-height: 64px; }
  .status-chip { display: none; }
  .intro-card { padding: 18px; border-radius: 22px; }
  h1 { font-size: 34px; }
  .generator-card,
  .output-card { padding: 18px; border-radius: 22px; }
  .form-row { grid-template-columns: 1fr; }
  .sticky-generate {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 45;
  }
  .sticky-generate .btn { min-height: 52px; border-radius: 18px; }
  .bottom-nav { display: flex; }
  .toast { bottom: 144px; }
  .processing-card { grid-template-columns: 1fr; text-align: center; }
  .spark-orb { margin: 0 auto; }
  .admin-layout { display: block; }
  .admin-layout aside {
    position: sticky;
    z-index: 30;
    height: auto;
    top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 12px;
  }
  .admin-layout aside h2 { flex: 0 0 auto; margin: 0 8px 0 0; font-size: 18px; }
  .admin-layout aside a { flex: 0 0 auto; margin: 0; }
  .admin-layout main { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .app-shell { width: calc(100% - 24px); padding-top: 14px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 14px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { font-size: 11px; }
  .intro-flow { width: 100%; justify-content: center; }
  .quick-presets { margin-left: -2px; margin-right: -2px; }
  .output-head { align-items: stretch; flex-direction: column; }
  .btn.ghost { width: 100%; }
  .empty-state { min-height: 330px; padding: 22px; }
  .result-section { padding: 14px; }
  .result-box { font-size: 15px; }
  table { min-width: 640px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
.install-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-card);
  padding: 30px;
}
.install-card h1 { font-size: 30px; line-height: 1.1; margin: 0 0 14px; }
.install-card p { color: var(--muted); line-height: 1.65; }
.install-card form { margin: 18px 0; }
code { border: 1px solid var(--line); background: #f8fafc; padding: 2px 6px; border-radius: 8px; color: var(--brand-dark); }
