/* ═══════════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surface */
  --bg-root:        #0b0d12;
  --bg-surface:     #131620;
  --bg-panel:       #181b27;
  --bg-input:       #0f1118;
  --bg-dz:          #111421;
  --bg-dz-hover:    #161a2e;

  /* Border */
  --border:         rgba(255,255,255,0.07);
  --border-focus:   #5b73f5;
  --border-success: #2ecc8f;
  --border-dz-drag: #5b73f5;

  /* Accent / Brand */
  --accent:         #5b73f5;
  --accent-dark:    #4055d4;
  --accent-glow:    rgba(91, 115, 245, 0.25);
  --accent-gradient: linear-gradient(135deg, #5b73f5 0%, #8b5cf6 100%);

  /* Text */
  --text-1:   #eceef5;
  --text-2:   #8891ab;
  --text-3:   #50576e;
  --text-code: #a5b4fc;

  /* Status */
  --success:  #2ecc8f;
  --error:    #f05252;
  --warning:  #f59e0b;

  /* Layout */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-xs: 5px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════════════ */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1700px;
  margin: 0 auto;
  height: 68px;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.header-logo-mark {
  color: var(--accent);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-1);
}

.header-sub {
  font-size: 0.75rem;
  color: var(--text-2);
  margin-top: 0.1rem;
}

.header-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-gradient);
  color: #fff;
  padding: 0.25rem 0.7rem;
  border-radius: 100px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════════════ */
.app-main {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem 2rem;
  max-width: 1700px;
  margin: 0 auto;
  min-height: calc(100vh - 68px);
  align-items: start;
}

/* ═══════════════════════════════════════════════════════════════════
   PANELS
═══════════════════════════════════════════════════════════════════ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-2);
  margin-bottom: 1.1rem;
}

.panel-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 1rem;
}
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 0.4rem;
}

.input-field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field::placeholder { color: var(--text-3); }

/* API key row */
.input-row {
  display: flex;
  gap: 0.4rem;
}

.input-row .input-field {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.btn-icon-only {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.18s, color 0.18s;
  padding: 0;
}

.btn-icon-only:hover {
  border-color: var(--border-focus);
  color: var(--text-1);
}

/* Select */
.select-wrapper {
  position: relative;
}

.select-wrapper .input-field {
  padding-right: 2.4rem;
  cursor: pointer;
}

.select-arrow {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-3);
  pointer-events: none;
}

option { background: var(--bg-panel); }

/* ═══════════════════════════════════════════════════════════════════
   DROP ZONES
═══════════════════════════════════════════════════════════════════ */
.drop-zone {
  background: var(--bg-dz);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  margin-bottom: 0.75rem;
  position: relative;
  outline: none;
}

.drop-zone:last-child { margin-bottom: 0; }

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--border-focus);
  background: var(--bg-dz-hover);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.drop-zone.drag-over {
  border-color: var(--border-dz-drag);
  background: rgba(91, 115, 245, 0.08);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 0 30px rgba(91,115,245,0.04);
}

.drop-zone.has-files {
  border-style: solid;
  border-color: var(--border-success);
  background: rgba(46, 204, 143, 0.04);
}

.dz-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.4rem;
}

.dz-icon svg {
  width: 30px;
  height: 30px;
  color: var(--text-3);
  transition: color 0.18s;
}

.drop-zone:hover .dz-icon svg,
.drop-zone.drag-over .dz-icon svg {
  color: var(--accent);
}

.drop-zone.has-files .dz-icon svg {
  color: var(--success);
}

.dz-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.dz-hint {
  font-size: 0.72rem;
  color: var(--text-3);
}

.dz-hint code {
  font-family: var(--font-mono);
  color: var(--text-code);
  background: rgba(165, 180, 252, 0.08);
  padding: 0.05em 0.3em;
  border-radius: 3px;
}

.dz-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dz-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-2);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.05rem 0.45rem;
  line-height: 1.6;
}

/* File list */
.file-list {
  list-style: none;
  margin-top: 0.65rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.74rem;
  color: var(--success);
  background: rgba(46, 204, 143, 0.08);
  border: 1px solid rgba(46, 204, 143, 0.15);
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-xs);
}

.file-item-check {
  flex-shrink: 0;
  font-size: 0.8rem;
}

.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-1);
  font-size: 0.74rem;
}

.file-item-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.file-item-remove:hover { color: var(--error); }

/* ═══════════════════════════════════════════════════════════════════
   GENERATE BUTTON
═══════════════════════════════════════════════════════════════════ */
.btn-generate {
  width: 100%;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  transition: opacity 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 20px rgba(91, 115, 245, 0.35);
  letter-spacing: -0.01em;
}

.btn-generate:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(91, 115, 245, 0.45);
}

.btn-generate:active:not(:disabled) {
  transform: translateY(0);
}

.btn-generate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════════
   STATUS BAR
═══════════════════════════════════════════════════════════════════ */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(91, 115, 245, 0.06);
  border: 1px solid rgba(91, 115, 245, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-2);
}

.status-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(91, 115, 245, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

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

/* ═══════════════════════════════════════════════════════════════════
   PREVIEW COLUMN
═══════════════════════════════════════════════════════════════════ */
.col-preview {
  position: sticky;
  top: calc(68px + 1.5rem);
  height: calc(100vh - 68px - 3rem);
  display: flex;
  flex-direction: column;
}

.preview-panel {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-export {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}

.btn-export:hover:not(:disabled) {
  border-color: var(--border-focus);
  color: var(--text-1);
  background: rgba(91, 115, 245, 0.08);
}

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

.preview-body {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Placeholder */
.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  gap: 0.75rem;
}

.placeholder-graphic svg {
  width: 80px;
  height: 80px;
  color: var(--text-3);
  opacity: 0.6;
}

.placeholder-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
}

.placeholder-desc {
  font-size: 0.82rem;
  color: var(--text-3);
  max-width: 320px;
}

.placeholder-desc strong {
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1214;
  border: 1px solid rgba(240, 82, 82, 0.4);
  color: var(--text-1);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.84rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  max-width: min(520px, calc(100vw - 2rem));
  animation: toast-in 0.22s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast-icon {
  width: 16px;
  height: 16px;
  color: var(--error);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.toast-message {
  flex: 1;
  line-height: 1.45;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0.1rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  margin-top: 0.1rem;
}

.toast-close:hover { color: var(--text-1); }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .col-preview {
    position: static;
    height: auto;
    min-height: 70vh;
  }

  .preview-body {
    min-height: 60vh;
  }
}

@media (max-width: 600px) {
  .app-header { padding: 0 1rem; }
  .header-sub { display: none; }
  .app-main { padding: 0.75rem; gap: 0.75rem; }
}
