/* ── AD-FORGE Console v2.0 Styles ── */

:root {
  --bg-0: #08080a;
  --bg-1: #111114;
  --bg-2: #1a1a1f;
  --bg-3: #232329;
  --border: #2a2a32;
  --border-focus: #3d3d4a;
  --text-0: #f0f0f2;
  --text-1: #b0b0ba;
  --text-2: #707078;
  --accent: #00e88f;
  --accent-dim: rgba(0,232,143,0.12);
  --accent-mid: rgba(0,232,143,0.3);
  --warn: #ff6b4a;
  --info: #4a9eff;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'DM Sans', system-ui, sans-serif;
  --radius: 6px;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 14px; }
body {
  font-family: var(--sans);
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  overflow-x: hidden;
}
::selection { background: var(--accent-mid); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* ── Header ── */
.header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand .logo {
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem;
  letter-spacing: 0.15em; color: var(--accent);
}
.header-brand .version {
  font-family: var(--mono); font-size: 0.6rem; color: var(--text-2);
  padding: 2px 6px; background: var(--bg-3); border-radius: 3px;
}
.header-actions { display: flex; gap: 8px; }

/* ── Sidebar ── */
.sidebar {
  grid-row: 2 / 4;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

/* ── Panels ── */
.panel { margin-bottom: 20px; }
.panel-title {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2);
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

/* ── Form ── */
.field { margin-bottom: 10px; }
.field label {
  display: block; font-size: 0.72rem; color: var(--text-1); margin-bottom: 3px;
}
.field input[type="text"],
.field input[type="number"],
.field select,
select {
  width: 100%; padding: 7px 10px;
  background: var(--bg-0); border: 1px solid var(--border);
  color: var(--text-0); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.78rem;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

/* ── Upload ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center; cursor: pointer;
  transition: all 0.2s; font-size: 0.72rem; color: var(--text-2);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent); background: var(--accent-dim); color: var(--text-1);
}
.upload-zone.has-file { border-color: var(--accent); border-style: solid; color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s;
  background: var(--bg-2); color: var(--text-0);
}
.btn:hover { border-color: var(--text-2); background: var(--bg-3); }
.btn-accent { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-accent:hover { background: #00ff9d; }
.btn-sm { padding: 4px 8px; font-size: 0.68rem; }
.btn-danger { color: var(--warn); border-color: rgba(255,107,74,0.3); }
.btn-danger:hover { background: rgba(255,107,74,0.1); border-color: var(--warn); }

/* ── Main ── */
.main { display: flex; flex-direction: column; overflow: hidden; }

/* ── Preview ── */
.preview-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
  background-color: var(--bg-0);
  background-image:
    linear-gradient(45deg, var(--bg-1) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-1) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-1) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-1) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.preview-frame {
  position: relative; background: #000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6); border-radius: 3px; overflow: hidden;
}
.preview-dims {
  position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.62rem; color: var(--text-2);
}
.preview-controls {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; z-index: 10;
}

/* ── Timeline ── */
.timeline-panel {
  grid-column: 2;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  min-height: 180px; max-height: 280px;
  display: flex; flex-direction: column;
}
.timeline-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tl-label {
  font-family: var(--mono); font-size: 0.68rem; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.tempo-control { display: flex; align-items: center; gap: 8px; }
.tempo-control label { font-family: var(--mono); font-size: 0.68rem; color: var(--text-2); text-transform: uppercase; }
.tempo-slider {
  -webkit-appearance: none; width: 100px; height: 4px;
  background: var(--bg-3); border-radius: 2px; outline: none;
}
.tempo-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  background: var(--accent); border-radius: 50%; cursor: grab;
}
.tempo-value { font-family: var(--mono); font-size: 0.72rem; color: var(--accent); min-width: 36px; text-align: center; }
.total-duration { font-family: var(--mono); font-size: 0.68rem; color: var(--text-2); }

.timeline-track-wrapper { flex: 1; overflow-x: auto; overflow-y: hidden; padding: 12px 16px; }
.timeline-track { display: flex; gap: 4px; min-height: 100px; align-items: stretch; }

/* Scene blocks */
.scene-block {
  position: relative; min-width: 110px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 4px;
}
.scene-block:hover { border-color: var(--text-2); }
.scene-block.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.scene-block-header { display: flex; align-items: center; justify-content: space-between; }
.scene-block-name { font-family: var(--mono); font-size: 0.68rem; font-weight: 600; }
.scene-block-dur { font-family: var(--mono); font-size: 0.62rem; color: var(--text-2); }
.scene-block-bar { width: 100%; height: 3px; border-radius: 2px; margin-top: auto; }
.scene-block-layers { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.layer-pill {
  font-family: var(--mono); font-size: 0.58rem; padding: 2px 6px;
  background: var(--bg-0); border-radius: 3px; color: var(--text-2);
}
.layer-pill .t { font-weight: 600; margin-right: 3px; }
.layer-pill .t-text { color: var(--info); }
.layer-pill .t-image { color: #e84aff; }
.layer-pill .t-cta { color: #ffcc00; }
.layer-pill .t-logo { color: #4affe8; }

.add-scene-block {
  min-width: 70px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: var(--radius);
  cursor: pointer; color: var(--text-2); font-size: 1.4rem; transition: all 0.15s;
}
.add-scene-block:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── Layer editor items (collapsible) ── */
.layer-item {
  background: var(--bg-0); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 6px; overflow: hidden;
  transition: border-color 0.15s;
}
.layer-item.expanded { border-color: var(--accent); }
.layer-item-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; cursor: pointer; user-select: none;
  transition: background 0.1s;
}
.layer-item-header:hover { background: var(--bg-2); }
.layer-item-summary {
  display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden;
}
.layer-collapse-icon {
  font-size: 0.65rem; color: var(--text-2); flex-shrink: 0; width: 12px;
}
.layer-color-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}
.layer-item-title {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layer-item-badge {
  font-family: var(--mono); font-size: 0.55rem; font-weight: 700;
  text-transform: uppercase; padding: 1px 4px; border-radius: 3px;
  flex-shrink: 0; letter-spacing: 0.03em;
}
.layer-badge-text { color: var(--info); background: rgba(74,158,255,0.12); }
.layer-badge-cta { color: #ffcc00; background: rgba(255,204,0,0.12); }
.layer-badge-image { color: #e84aff; background: rgba(232,74,255,0.12); }
.layer-badge-logo { color: #4affe8; background: rgba(74,255,232,0.12); }
.layer-item-anim {
  font-family: var(--mono); font-size: 0.58rem; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layer-item-actions {
  display: flex; gap: 3px; flex-shrink: 0; margin-left: 6px;
}
.layer-item-body { padding: 8px; border-top: 1px solid var(--border); }

/* ── Locale tags ── */
.locale-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; background: var(--bg-3); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.68rem; color: var(--text-1);
}
.locale-tag .x { cursor: pointer; color: var(--text-2); }
.locale-tag .x:hover { color: var(--warn); }

/* ── Target grid ── */
.target-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.target-option {
  display: flex; align-items: center; gap: 5px; padding: 4px 6px;
  border-radius: var(--radius); cursor: pointer; font-size: 0.68rem; color: var(--text-1);
}
.target-option:hover { background: var(--bg-3); }
.target-option input { accent-color: var(--accent); }

/* ── Asset list ── */
.asset-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; background: var(--bg-0); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.65rem; color: var(--text-1);
  margin-bottom: 4px;
}
.asset-thumb {
  width: 28px; height: 28px; object-fit: cover; border-radius: 3px;
  border: 1px solid var(--border); flex-shrink: 0; background: var(--bg-2);
}
.asset-item .asset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.asset-item .copy-url {
  cursor: pointer; color: var(--text-2); font-size: 0.7rem;
  padding: 2px 4px; border-radius: 3px;
}
.asset-item .copy-url:hover { color: var(--accent); background: var(--accent-dim); }

/* ── Style Controls ── */
.img-src-field { display: flex; align-items: center; gap: 6px; }
.layer-img-preview {
  width: 36px; height: 36px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--border); flex-shrink: 0; background: var(--bg-2);
}
.style-section { margin-top: 8px; }
.style-divider {
  font-family: var(--mono); font-size: 0.6rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2); margin: 8px 0 6px 0;
  padding-top: 6px; border-top: 1px dashed var(--border);
}
.color-field {
  display: flex; align-items: center; gap: 4px;
}
.color-field input[type="color"] {
  width: 28px; height: 28px; padding: 1px; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; background: var(--bg-0);
  flex-shrink: 0;
}
.color-field input[type="text"] {
  padding: 6px 8px; background: var(--bg-0); border: 1px solid var(--border);
  color: var(--text-0); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.72rem;
}

/* ── Toasts ── */
.toast-container { position: fixed; top: 160px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border-radius: var(--radius); font-family: var(--mono); font-size: 0.72rem;
  animation: toastIn 0.3s ease-out; max-width: 360px;
}
.toast-success { background: var(--accent-dim); border: 1px solid var(--accent); color: var(--accent); }
.toast-error { background: rgba(255,107,74,0.1); border: 1px solid var(--warn); color: var(--warn); }
.toast-info { background: rgba(74,158,255,0.1); border: 1px solid var(--info); color: var(--info); }
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
