/* ============================================================
   Primia Slides — Design System Primia-OS
   Dark-first, "Laboratorio Noturno"
   ============================================================ */

:root {
  --background: #040404;
  --foreground: #ffffff;
  --card: #0d0d0e;
  --card-alt: #19191c;
  --muted: #212529;
  --muted-foreground: #99999e;
  --text-secondary: #dfdfe0;
  --primary: #721ae7;
  --primary-hover: #6816d6;
  --destructive: #ff5e40;
  --destructive-soft: #d97757;
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-border: rgba(255, 255, 255, 0.09);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-pill: 50px;
  --shadow-purple-glow: 0 0 40px 0 rgba(114, 26, 231, 0.4), 0 0 80px 0 rgba(114, 26, 231, 0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--background);
  color: var(--foreground);
  font-family: 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  position: relative;
  background-image: radial-gradient(
    ellipse at top right,
    rgba(114, 26, 231, 0.25) 0%,
    rgba(4, 4, 4, 0) 60%
  );
  background-attachment: fixed;
}

/* Grain SVG fixo */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #9c60eb; }

/* ============ Layout ============ */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 32px 80px;
  position: relative;
  z-index: 1;
}

@media (max-width: 700px) {
  .container { padding: 32px 18px 60px; }
}

/* ============ Tipografia ============ */

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted-foreground);
  margin-bottom: 14px;
}

.section-label::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.page-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.page-title em {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: var(--primary);
}

.page-description {
  margin-top: 16px;
  max-width: 620px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted-foreground);
}

.page-description a { color: var(--primary); }

.field-label,
label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted-foreground);
}

.muted { color: var(--muted-foreground); font-size: 13px; }

/* ============ Header da pagina ============ */

.page-header {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-soft);
}

/* ============ Toolbar ============ */

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

@media (max-width: 900px) {
  .toolbar { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .toolbar { grid-template-columns: 1fr; }
}

/* ============ Inputs / Selects / Textareas ============ */

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--foreground);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
}

textarea { resize: vertical; min-height: 80px; font-family: inherit; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2399999E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============ Cards ============ */

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
  transition: border-color 0.2s, background 0.2s;
}

.card:hover { border-color: rgba(255, 255, 255, 0.16); }

.slide-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.slide-card-number {
  position: absolute;
  top: -8px;
  right: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 110px;
  font-weight: 300;
  line-height: 1;
  color: rgba(255, 255, 255, 0.04);
  pointer-events: none;
  user-select: none;
  transition: color 0.4s;
}

.slide-card:hover .slide-card-number { color: rgba(114, 26, 231, 0.15); }

.slide-card-inner {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
  position: relative;
  z-index: 1;
}

@media (max-width: 800px) {
  .slide-card-inner { grid-template-columns: 1fr; }
}

.slide-card-left { display: flex; flex-direction: column; gap: 14px; }

.slide-card-right { position: sticky; top: 24px; }

.slide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.slide-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--primary);
}

.slide-fields { display: flex; flex-direction: column; gap: 14px; }

/* ============ Preview de imagem ============ */

.slide-preview-panel {
  background: var(--card-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide-preview-panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.slide-preview-placeholder {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.18);
  text-align: center;
  padding: 20px;
}

/* ============ Upload de imagem ============ */

.image-upload {
  border: 1px dashed var(--input-border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.image-upload:hover {
  border-color: var(--primary);
  background: rgba(114, 26, 231, 0.03);
}

.image-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.image-upload .upload-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted-foreground);
}

.image-upload .upload-preview {
  max-height: 150px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  width: 100%;
  display: none;
}

/* ============ Botoes ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow-purple-glow);
}

.btn-primary-block {
  width: 100%;
  margin-top: 32px;
  padding: 18px 32px;
  font-size: 12px;
}

.btn-secondary {
  background: transparent;
  color: var(--foreground);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.03);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border: 1px solid transparent;
  padding: 8px 14px;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--foreground);
  background: rgba(255, 255, 255, 0.04);
}

.btn-add {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted-foreground);
  padding: 22px;
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}

.btn-add:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(114, 26, 231, 0.04);
}

.remove-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  transition: all 0.15s;
}

.remove-btn:hover {
  color: var(--destructive);
  border-color: var(--destructive);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ============ Progress / results / status ============ */

.progress, .results {
  display: none;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 24px;
}

.progress.active, .results.active { display: block; }

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 16px auto 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.preview-item img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

/* ============ Status badges ============ */

.status {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  display: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.status.show { display: block; }

.status.ok {
  background: rgba(3, 152, 85, 0.08);
  border: 1px solid rgba(3, 152, 85, 0.3);
  color: #4ade80;
}

.status.err {
  background: rgba(255, 94, 64, 0.08);
  border: 1px solid rgba(255, 94, 64, 0.3);
  color: #ff8a73;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(3, 152, 85, 0.1);
  border: 1px solid rgba(3, 152, 85, 0.3);
  color: #4ade80;
}

.badge.err {
  background: rgba(255, 94, 64, 0.1);
  border: 1px solid rgba(255, 94, 64, 0.3);
  color: #ff8a73;
}

/* ============ Provider rows (config.html) ============ */

.provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-soft);
  gap: 18px;
}

.provider-row:last-child { border-bottom: none; }

.provider-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }

.provider-label {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--foreground);
}

.provider-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted-foreground);
  word-break: break-all;
  letter-spacing: 0.02em;
}

.hint {
  background: rgba(114, 26, 231, 0.04);
  border-left: 2px solid var(--primary);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

code {
  background: var(--card-alt);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

pre {
  background: var(--card-alt);
  border: 1px solid var(--border-soft);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* ============ Scrollbar ============ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #313135; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b4b53; }
