/* ─────────────────────────────────────────────────────
   Patta Gadgets Automater — Modern Symmetrical Design System
   Sleek Dark Slate Palette, Standard Spacing & Typography.
───────────────────────────────────────────────────── */

:root {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --surface-2:    #334155;
  --surface-hover:#3b4d66;
  --border:       #334155;
  --border-light: #475569;
  --text:         #f8fafc;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;

  --primary:      #3b82f6;
  --primary-hover:#2563eb;
  --primary-bg:   rgba(59, 130, 246, 0.12);

  --danger:       #ef4444;
  --danger-hover: #dc2626;
  --danger-bg:    rgba(239, 68, 68, 0.12);

  --success:      #10b981;
  --success-hover:#059669;
  --success-bg:   rgba(16, 185, 129, 0.12);

  --warning:      #f59e0b;
  --warning-hover:#d97706;
  --warning-bg:   rgba(245, 158, 11, 0.12);

  --status-draft:       #94a3b8;
  --status-processing:  #60a5fa;
  --status-needs-hook:  #fbbf24;
  --status-needs-script:#fbbf24;
  --status-ready:       #34d399;
  --status-done:        #34d399;

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow:    0 4px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5);

  --font-sinhala: 'Noto Sans Sinhala', 'Iskoola Pota', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: #60a5fa; text-decoration: none; }

/* ── App Layout ──────────────────────────────────────── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.2px;
}
.brand-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 2px 7px;
  border-radius: 999px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 6px;
  border-radius: var(--radius);
  border: 1px solid rgba(51, 65, 85, 0.6);
}
.topbar-nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s ease;
}
.topbar-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}
.topbar-nav a.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.5);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.page-content {
  flex: 1;
  padding: 32px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ── Page Header ─────────────────────────────────────── */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ── Cards & Surfaces ────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.card + .card { margin-top: 20px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.1px;
}
.card-title-muted {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}
.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #64748b;
}
.btn-outline-danger {
  background: transparent;
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger);
}
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 22px; font-size: 14px; font-weight: 600; border-radius: var(--radius); }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }

/* ── Form Controls ───────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
input[type=text], input[type=password], input[type=email], input[type=search], input[type=date],
select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  transition: all .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
textarea.script-box {
  min-height: 200px;
  font-family: var(--font-sinhala);
  font-size: 15px;
  line-height: 1.8;
  padding: 14px;
}

/* ── Toolbar Card (Filters) ──────────────────────────── */
.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.toolbar-card input[type=search] { flex: 1; min-width: 220px; max-width: 340px; }
.toolbar-card select { width: auto; min-width: 160px; }

/* ── Status Badges ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-draft         { background: rgba(148, 163, 184, 0.12); color: var(--status-draft); border: 1px solid rgba(148, 163, 184, 0.25); }
.badge-processing    { background: var(--primary-bg); color: var(--status-processing); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-needs-hook    { background: var(--warning-bg); color: var(--status-needs-hook); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-needs-script  { background: var(--warning-bg); color: var(--status-needs-script); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-ready         { background: var(--success-bg); color: var(--status-ready); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-done          { background: var(--success-bg); color: var(--status-done); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-error         { background: var(--danger-bg); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }

/* ── Progress Stepper ────────────────────────────────── */
.stepper-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stepper-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .2s;
  position: relative;
}
.stepper-step.completed {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}
.stepper-step.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px var(--primary);
}
.stepper-step.disabled {
  opacity: 0.5;
}
.step-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.stepper-step.completed .step-number {
  background: var(--success);
  color: #fff;
}
.stepper-step.active .step-number {
  background: var(--primary);
  color: #fff;
}
.step-info { flex: 1; min-width: 0; }
.step-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-desc { font-size: 11px; color: var(--text-muted); }

/* ── Product Table ───────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.product-table {
  width: 100%;
  border-collapse: collapse;
}
.product-table th, .product-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.product-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-weight: 700;
  background: var(--surface-2);
}
.product-table tr.product-row {
  transition: background .15s;
}
.product-table tr.product-row:hover td {
  background: rgba(51, 65, 85, 0.4);
}
.product-table tr.no-hover:hover td { background: transparent; cursor: default; }

.table-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: block;
}

.table-actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Symmetrical Hero Card (Product Detail) ───────────── */
.product-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.hero-gallery {
  display: flex;
  gap: 10px;
}
.hero-main-img {
  width: 90px;
  height: 90px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border-light);
  background: var(--surface-2);
}
.hero-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hero-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}
.hero-meta-item strong { color: var(--text); }
.hero-actions-hub {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* ── Hook Grid (Symmetrical 2-Column) ────────────────── */
.hook-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.hook-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}
.hook-card:hover {
  border-color: var(--primary);
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.hook-card.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}
.hook-card.chosen-locked {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.08);
  cursor: default;
  transform: none;
}
.hook-card-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  margin-bottom: 12px;
}
.hook-line-text {
  font-family: var(--font-sinhala);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 12px;
}
.hook-preview-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.hook-card-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(51, 65, 85, 0.6);
  padding-top: 14px;
}

/* ── Prompts Grid (Symmetrical 2-Column) ──────────────── */
.prompts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.prompt-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.prompt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.prompt-card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.prompt-text-content {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  flex: 1;
  max-height: 340px;
  overflow-y: auto;
}

/* ── Error Banner ────────────────────────────────────── */
.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.error-banner-title {
  font-weight: 700;
  font-size: 14px;
  color: #f87171;
  display: flex;
  align-items: center;
  gap: 8px;
}
.error-banner-msg {
  font-size: 13px;
  color: #fca5a5;
  margin-top: 4px;
  line-height: 1.5;
  word-break: break-word;
}

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ── Drag & Drop Zone ────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
  background: var(--bg);
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--text);
}
.drop-zone input[type=file] { display: none; }
.drop-zone-icon { font-size: 32px; margin-bottom: 8px; }
.preview-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.preview-grid img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border-light); }

/* ── Character Card Grid (Settings / Script) ─────────── */
.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.char-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.char-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.char-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

/* ── Tabs ────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Spinner ─────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── Toast notifications ─────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { background: #064e3b; color: #6ee7b7; border: 1px solid #059669; }
.toast-error   { background: #7f1d1d; color: #fca5a5; border: 1px solid #ef4444; }
.toast-info    { background: #1e3a8a; color: #93c5fd; border: 1px solid #3b82f6; }

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 44px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 13px; color: var(--text-muted); }

/* ── Misc Utility ────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-dim { color: var(--text-dim); }
.fw-600 { font-weight: 600; }
.w-full { width: 100%; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .stepper-container { grid-template-columns: 1fr 1fr; }
  .product-hero-card { grid-template-columns: 1fr; }
  .hero-actions-hub { align-items: flex-start; }
  .hook-grid { grid-template-columns: 1fr; }
  .prompts-grid { grid-template-columns: 1fr; }
  .char-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ── Scrollbars ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
