/* =========================================================================
 *  ABMedia · Story Builder — tema oscuro con tonos naranjas
 * ========================================================================= */
:root {
  --bg:        #0c0a09;
  --bg-2:      #141110;
  --panel:     #1a1614;
  --panel-2:   #211b18;
  --border:    #2b2420;
  --text:      #f4efe9;
  --muted:     #9a8f85;
  --faint:     #6b6258;

  --orange:    #ff6a1a;
  --orange-2:  #ff8a3d;
  --orange-dk: #d4520c;
  --orange-soft: rgba(255, 106, 26, 0.14);

  --radius:    14px;
  --shadow:    0 18px 50px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 80% -10%, #1c1512 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

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

/* ---------------------------- Sidebar ---------------------------------- */
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border);
  padding: 26px 20px;
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #1a0f08;
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
  box-shadow: 0 6px 18px rgba(255,106,26,0.35);
}
.brand strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  font-size: 14px; color: var(--muted); padding: 11px 13px;
  border-radius: 10px; cursor: pointer; transition: .15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: var(--orange-soft); color: var(--orange-2);
  font-weight: 600;
}

.upload-card {
  margin-top: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.upload-title { font-size: 13px; font-weight: 600; }
.upload-sub { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }
.upload-sub.ok { color: var(--orange-2); }
.upload-note { font-size: 11px; color: var(--faint); margin-top: 10px; line-height: 1.4; }

/* ---------------------------- Botones ---------------------------------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  padding: 11px 18px; transition: .15s; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn.sm { padding: 8px 13px; font-size: 13px; }
.btn.full { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
  color: #1a0f08; box-shadow: 0 8px 22px rgba(255,106,26,0.30);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-ghost { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--orange); color: var(--orange-2); }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 15px;
}
.icon-btn:hover { color: var(--text); border-color: var(--orange); }

/* ---------------------------- Topbar ----------------------------------- */
.content { padding: 30px 36px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; }
.topbar h1 { font-size: 28px; font-weight: 800; letter-spacing: -.4px; }
.topbar p { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ---------------------------- Desk grid -------------------------------- */
.desk { display: grid; grid-template-columns: 320px 1fr; gap: 26px; align-items: start; }

/* Inbox */
.inbox {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.inbox-head .chip {
  font-size: 10px; letter-spacing: 2px; font-weight: 700;
  color: var(--orange-2); background: var(--orange-soft);
  padding: 4px 9px; border-radius: 6px;
}
.inbox-head h2 { font-size: 18px; margin: 12px 0 4px; }
.inbox-head p { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-bottom: 16px; }
.inbox-list { display: flex; flex-direction: column; gap: 12px; }
.inbox-item {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 14px;
}
.inbox-item p { font-size: 13.5px; line-height: 1.45; }
.inbox-item .meta { display: block; font-size: 10.5px; letter-spacing: .6px; color: var(--faint); margin: 9px 0 11px; }
.inbox-item .btn { width: 100%; }

/* Pipeline */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  font-family: inherit; font-size: 13px; color: var(--muted);
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 13px; cursor: pointer; transition: .15s;
}
.tab .count { color: var(--faint); font-size: 11px; margin-left: 4px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--orange-soft); border-color: transparent; color: var(--orange-2); font-weight: 600; }
.tab.active .count { color: var(--orange); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.card {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: .18s;
}
.card:hover { transform: translateY(-3px); border-color: var(--orange); box-shadow: var(--shadow); }
.card-canvas { width: 100%; display: block; aspect-ratio: 9/16; object-fit: cover; background: #15110d; }
.frames-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-weight: 600; color: var(--text);
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  padding: 4px 9px; border-radius: 6px;
}
.card-info { padding: 13px 14px 15px; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-info h3 { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.edit-hint { display: block; font-size: 11px; color: var(--faint); margin-top: 9px; letter-spacing: .3px; }

.review-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 10px; font-weight: 600; color: #1a0f08;
  background: var(--orange-2); padding: 4px 8px; border-radius: 6px;
}
.cat-tag { font-size: 11px; color: var(--orange-2); font-weight: 600; white-space: nowrap; }
.card-obj { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 8px 0 12px; }

/* Chips de categoría (Biblioteca) */
.chips { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 22px; }
.chip-btn {
  font-family: inherit; font-size: 13.5px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; transition: .15s;
}
.chip-btn:hover { color: var(--text); border-color: var(--orange); }
.chip-btn.active { background: var(--orange-soft); border-color: transparent; color: var(--orange-2); font-weight: 600; }

/* Herramientas de "Mis secuencias" */
.mine-tools { display: flex; gap: 8px; padding: 0 14px 14px; }
.mine-tools .btn { flex: 1; }
.btn.xs { padding: 7px 10px; font-size: 12px; }
.btn.danger { flex: 0 0 auto; }
.btn.danger:hover { border-color: #e5484d; color: #ff6b6e; }

.status { font-size: 9.5px; font-weight: 700; letter-spacing: .5px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; text-transform: uppercase; }
.st-draft     { background: #2a2520; color: #b6a99c; }
.st-progress  { background: var(--orange-soft); color: var(--orange-2); }
.st-scheduled { background: rgba(96,165,250,0.16); color: #7cb1ff; }
.st-published { background: rgba(74,222,128,0.16); color: #6ee79a; }

.empty { color: var(--faint); font-size: 13px; padding: 16px 0; }

/* ---------------------------- Modal plantillas ------------------------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 40; }
.modal-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px; width: min(720px, 92vw); padding: 24px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 19px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tpl-card {
  text-align: left; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; cursor: pointer; transition: .15s;
  display: flex; flex-direction: column; gap: 7px; font-family: inherit; color: var(--text);
}
.tpl-card:hover { border-color: var(--orange); transform: translateY(-2px); }
.tpl-card strong { font-size: 15px; }
.tpl-card span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.tpl-card em { font-size: 11px; color: var(--orange-2); font-style: normal; font-weight: 600; margin-top: 2px; }

/* ---------------------------- Editor overlay --------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.editor { background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px; width: min(1180px, 96vw); max-height: 94vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.editor-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.editor-titlewrap { display: flex; align-items: center; gap: 12px; flex: 1; }
.editor-title { font-family: inherit; font-size: 17px; font-weight: 700; color: var(--text); background: transparent; border: none; border-bottom: 1px solid transparent; padding: 4px 0; flex: 1; max-width: 520px; }
.editor-title:focus { outline: none; border-bottom-color: var(--orange); }
.status-select, #fontSelect {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; cursor: pointer;
}

.editor-body { display: grid; grid-template-columns: minmax(220px, 300px) 130px 1fr; gap: 22px; padding: 22px; overflow: auto; }

.preview-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.preview { width: 100%; max-width: 280px; aspect-ratio: 9/16; border-radius: 12px; background: #15110d; box-shadow: var(--shadow); }
.preview-actions { display: flex; gap: 8px; }

.frames-col .col-label, .col-label { font-size: 11px; letter-spacing: 1px; color: var(--faint); text-transform: uppercase; margin-bottom: 12px; }
.thumbs { display: flex; flex-direction: column; gap: 10px; }
.thumb { background: transparent; border: 2px solid transparent; border-radius: 9px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.thumb canvas { width: 72px; border-radius: 6px; background: #15110d; }
.thumb span { font-size: 10px; color: var(--muted); text-align: center; }
.thumb.active { border-color: var(--orange); }
.thumb.active span { color: var(--orange-2); }

.edit-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dropzone {
  border: 1.5px dashed var(--border); border-radius: 12px; padding: 16px;
  text-align: center; cursor: pointer; transition: .15s; background: var(--panel);
  display: flex; flex-direction: column; gap: 3px;
}
.dropzone:hover, .dropzone.hover { border-color: var(--orange); background: var(--orange-soft); }
.dropzone strong { font-size: 13px; }
.dropzone span { font-size: 11.5px; color: var(--muted); }

.edit-slide { font-size: 15px; color: var(--orange-2); }
.text-panel { display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); }
.field input, .field textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--orange); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field.inline input[type=color] { width: 44px; height: 32px; padding: 2px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); cursor: pointer; }

.style-row { display: flex; gap: 14px; flex-wrap: wrap; }
.style-row .field.inline { flex: 1; min-width: 150px; }
.drag-hint { font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.4; max-width: 280px; }
.icon-btn.sm { width: 30px; height: 30px; font-size: 14px; }
.icon-btn.sm.danger:hover { border-color: #e5484d; color: #ff6b6e; }
.frame-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.frame-actions { display: flex; gap: 6px; }
.zoom-field { width: 100%; max-width: 280px; }
.bg-picker { display: flex; gap: 6px; flex-wrap: wrap; max-width: 280px; justify-content: center; }
.bg-thumb { padding: 0; border: 2px solid transparent; border-radius: 7px; cursor: pointer; background: none; line-height: 0; }
.bg-thumb canvas { border-radius: 5px; display: block; }
.bg-thumb.active { border-color: var(--orange); }
.bg-empty { font-size: 11px; color: var(--faint); }

/* Login screen */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(900px 600px at 70% -10%, #1c1410 0%, var(--bg) 65%); z-index: 100; padding: 20px; }
.login-box { width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-brand { margin-bottom: 4px; }
.login-box h2 { font-size: 22px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.login-err { color: #ff6b6e; font-size: 12.5px; min-height: 16px; margin: -4px 0 0; }

/* Top user info */
.user-mini { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 10px; padding: 8px 4px; border-top: 1px solid var(--border); }
.user-mini #userEmail { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.mark-hint { font-size: 11px; color: var(--faint); }
.thumb.add { display: grid; place-items: center; min-height: 160px; border: 1.5px dashed var(--border); color: var(--muted); font-size: 24px; }
.thumb.add:hover { border-color: var(--orange); color: var(--orange-2); }
.inset-block { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.inset-block #insetControls { display: flex; flex-direction: column; gap: 10px; }
input[type=range] { accent-color: var(--orange); width: 100%; }

.save-row { display: flex; gap: 10px; margin-top: auto; }
.save-row .btn { flex: 1; }
.download-row { display: flex; gap: 10px; }
.download-row .btn { flex: 1; }

/* ---------------------------- Responsive ------------------------------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 16px; }
  .upload-card { margin: 0; flex: 1; min-width: 220px; }
  .desk { grid-template-columns: 1fr; }
  .editor-body { grid-template-columns: 1fr; }
  .frames-col .thumbs { flex-direction: row; flex-wrap: wrap; }
}

/* Editor en móvil: una columna, preview arriba, frames en fila */
@media (max-width: 760px) {
  .content { padding: 18px 16px 36px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar h1 { font-size: 22px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

  .overlay { padding: 0; }
  .editor { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .editor-top { padding: 14px 16px; }
  .editor-title { font-size: 15px; }
  .editor-body { padding: 16px; gap: 18px; }
  .preview { max-width: 60vw; }
  .frames-col { order: 3; }
  .frames-col .thumbs { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .thumb canvas { width: 56px; }
  .thumb.add { min-height: auto; width: 64px; }
  .style-row { flex-direction: column; }
  .style-row .field.inline { width: 100%; }
  .save-row, .download-row { flex-direction: column; }
  .bg-picker, .zoom-field, .drag-hint { max-width: 100%; }
}
