/* =========================================================
 * Lodes Editor - app.css (cleaned & consolidated)
 * ========================================================= */

/* -------------------------
 * Theme / Variables
 * ------------------------- */
:root{
  --bg:#f6f7f9;
  --panel:#ffffff;
  --border:#e6e8ee;
  --text:#1b1f2a;
  --muted:#6b7280;
  --primary:#2f6fed;
  --primary-2:#1f57c9;

  --left-w:300px;
  --right-w:400px;
  --top-h:56px;
}

/* -------------------------
 * Reset / Base
 * ------------------------- */
*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color:var(--text);
  background:var(--bg);
}

.hidden { display:none !important; }

/* -------------------------
 * App Layout
 * ------------------------- */
.app{
  height:100%;
  display:flex;
  flex-direction:column;
}

.layout{
  flex:1;
  display:grid;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
  min-height:0;
}

.left, .right{
  overflow:auto;
  padding:10px;
}

.main{
  overflow:auto;
  padding:10px 14px;
  min-height:0;
}

/* -------------------------
 * Topbar
 * ------------------------- */
.topbar{
  height:var(--top-h);
  display:flex;
  align-items:center;
  gap:16px;
  padding:8px 12px;
  background:var(--panel);
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  z-index:10;
}

.brand{
  font-weight:700;
  min-width:120px;
}

.topic{
  display:flex;
  align-items:center;
  gap:8px;
  flex:1;
  min-width:320px;
  position:relative; /* for drop-hint */
}

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

/* md drop hint (Topbar topic area) */
.drop-hint{
  display:none;
  position:absolute;
  left:0;
  right:0;
  top: calc(100% + 6px);
  padding:6px 10px;
  border:1px dashed var(--border);
  border-radius:10px;
  background:#fff;
}

.topic.dragover{
  outline:2px dashed rgba(47,111,237,.45);
  outline-offset:4px;
}
.topic.dragover .drop-hint{ display:block; }

/* -------------------------
 * Typography / Utilities
 * ------------------------- */
.label{
  font-size:12px;
  color:var(--muted);
}

.h1{
  font-size:18px;
  font-weight:800;
  margin-bottom:4px;
}

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

.hint{
  font-size:13px;
  padding:6px 8px;
  background:#f3f4f6;
  border-radius:8px;
}

/* -------------------------
 * Form Controls
 * ------------------------- */
.input, .textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:8px;
  padding:9px 10px;
  outline:none;
  background:#fff;
  font-size:14px;
}
.textarea{ resize:vertical; }

/* Topbar compact select/input (keep your original behavior) */
.input-compact{
  width:auto;
  min-width:180px;
  max-width:240px;
}

/* -------------------------
 * Buttons
 * ------------------------- */
.btn{
  border:1px solid var(--border);
  background:#fff;
  padding:8px 10px;
  border-radius:8px;
  cursor:pointer;
  font-size:13px;
  white-space:nowrap;
}
.btn:hover{ background:#fafafa; }

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

.btn.loading {
  position:relative;
  padding-right:2.2em;
  cursor:not-allowed;
  opacity:0.85;
}
.btn.loading::after{
  content:"";
  position:absolute;
  right:0.8em;
  top:50%;
  width:1em;
  height:1em;
  margin-top:-0.5em;
  border:2px solid currentColor;
  border-top-color:transparent;
  border-radius:999px;
  animation: btnSpin 0.75s linear infinite;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* -------------------------
 * Panels / Lists
 * ------------------------- */
.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px;
  margin-bottom:10px;
}

.panel-title{
  font-size:13px;
  font-weight:700;
  margin-bottom:8px;
}

.panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.panel-head .panel-title{
  margin-bottom:0; /* avoid double margin */
}

.row{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:8px;
}

.list{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.list-item{
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px 8px;
  cursor:pointer;
  background:#fff;
}
.list-item:hover{ background:#fafafa; }
.list-item.active{
  outline:2px solid var(--primary);
  border-color:transparent;
}
.list-title{ font-size:13px; font-weight:700; }
.list-sub{ font-size:12px; color:var(--muted); margin-top:2px; }

/* -------------------------
 * Main Head
 * ------------------------- */
.main-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

/* -------------------------
 * Scenes
 * ------------------------- */
.scenes{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.scene{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
}

.scene.active{
  outline:3px solid #f59e0b; /* orange */
  border-color:transparent;
}

/* scene header: single row */
.scene-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:8px;
}

/* left zone: textarea + mini controls in one line */
.scene-left{
  flex:1;
  min-width:0;
  display:flex;
  align-items:center;
  gap:12px;
}

/* textarea grows, controls keep compact */
.scene-input{
  flex:1;
  min-width:260px;

  /* keep your original visual */
  min-height:44px;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
  font-size:14px;
  font-weight:700;
  line-height:1.35;
  background:#fff;
  outline:none;
  resize:vertical;
}

.scene.active .scene-input{
  border-color:transparent;
  box-shadow:0 0 0 3px rgba(245,158,11,.35);
}

/* mini controls: one line, no extra top margin */
.scene-mini{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:0;
  flex-wrap:nowrap;
  white-space:nowrap;
}

.scene-mini-item{
  display:inline-flex;
  align-items:center;
  gap:8px;
}

/* right actions */
.scene-actions{
  display:inline-flex;
  gap:6px;
  white-space:nowrap;
  flex:0 0 auto;
}

.icon-btn{
  width:30px;
  height:30px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.15);
  background:rgba(255,255,255,0.06);
  color:inherit;
  cursor:pointer;
  line-height:28px;
  text-align:center;
}
.icon-btn:hover{ background:rgba(255,255,255,0.12); }

/* IMPORTANT: you asked "開始秒數" only small number.
   We DO NOT require HTML changes: we target the dataset attribute. */
input[data-start-sec]{
  width:72px;
  min-width:72px;
  max-width:80px;
  text-align:center;
  padding:9px 10px; /* match .input */
}

/* Also keep avatar-layout select compact without changing HTML */
select[data-avatar-layout]{
  width:auto;
  min-width:110px;
  max-width:160px;
}

/* -------------------------
 * Assets (video/image cards)
 * ------------------------- */
.asset-row{
  overflow:visible;
  padding:4px;
}

.asset-scroll{
  display:flex;
  gap:10px;
  overflow-x:auto;
  overflow-y:visible;
  padding:12px;
}

.asset{
  flex:0 0 auto;
  padding:0;
  border:0;
  background:transparent;
  cursor:pointer;
  user-select:none;
  position:relative;
  height:auto;
  min-width:0;
  display:block;
}

.asset:hover .asset-preview{ filter:brightness(0.98); }

/* single source of truth for preview box */
.asset-preview{
  position:relative;
  width:260px;
  aspect-ratio:9/16; /* default portrait; JS may update */
  border-radius:14px;
  overflow:hidden;
  background:#f3f4f6;
}

/* outline lives on preview */
.asset.active .asset-preview{
  outline:3px solid var(--primary);
  outline-offset:6px;
}

.asset-video{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
  background:rgba(0,0,0,0.08);
}

/* image support */
.asset-img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
  background:rgba(0,0,0,0.08);
}

.asset-select-layer{
  position:absolute;
  left:0;
  right:0;
  top:0;
  bottom:52px;      /* reserve controls area */
  z-index:20;
  background:transparent;
  cursor:pointer;
}

.asset-check{
  position:absolute;
  top:10px;
  right:10px;
  z-index:50;
  font-size:18px;
  line-height:1;
  background:rgba(255,255,255,0.95);
  border-radius:10px;
  padding:4px 6px;
  pointer-events:none;
}

.asset-fallback{
  position:absolute;
  left:10px;
  right:10px;
  bottom:10px;
  z-index:6;
}

.asset-meta{ min-width:0; }

.asset-url{
  display:block;
  font-size:12px;
  line-height:1.3;
  word-break:break-all;
  text-decoration:underline;
}

.asset-label{ font-size:13px; font-weight:700; }
.asset-sub{ font-size:12px; color:var(--muted); margin-top:6px; }

/* -------------------------
 * Status / Footer / Export
 * ------------------------- */
.status{ margin-top:6px; }

.footer-actions{
  position:sticky;
  bottom:0;
  background:var(--panel);
}

.export{
  margin-top:10px;
  border-top:1px solid var(--border);
  padding-top:10px;
}
.export-title{
  font-size:13px;
  font-weight:700;
  margin-bottom:8px;
}

.progress{
  width:100%;
  height:10px;
  border:1px solid var(--border);
  border-radius:999px;
  overflow:hidden;
  background:#f3f4f6;
}
.progress-bar{
  height:100%;
  background:var(--primary);
  width:0%;
}

/* -------------------------
 * Upload Zone
 * ------------------------- */
.upload-zone{
  margin-top:10px;
  padding:10px;
  border:1px dashed rgba(255,255,255,.25);
  border-radius:10px;
  cursor:pointer;
  user-select:none;
}

.upload-zone.dragover{ border-style:solid; }
.upload-zone.busy{
  opacity:.7;
  cursor:not-allowed;
}

/* You said: "拖曳提示文字不要出現" -> 你可以在 HTML 不放 upload-title；
   但如果仍存在，這邊不改你的邏輯，只保留樣式。 */
.upload-zone .upload-title{ font-size:13px; }
.upload-zone .upload-status{
  margin-top:6px;
  font-size:12px;
}

.upload-list{
  margin-top:8px;
  display:grid;
  gap:8px;
}

.upload-item{
  padding:8px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:10px;
}

.upload-item-head{
  display:flex;
  justify-content:space-between;
  gap:10px;
}

.upload-name{
  font-size:12px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.upload-bar{
  margin-top:6px;
  height:8px;
  border-radius:999px;
  overflow:hidden;
  background:rgba(255,255,255,.12);
}

.upload-bar-inner{
  height:100%;
  width:0%;
  background:rgba(255,255,255,.55);
}

.upload-msg{
  margin-top:6px;
  font-size:12px;
}

/* compact upload zone (no title text) */
.upload-zone-compact{
  min-height:18px;
  padding:8px;
}

/* -------------------------
 * Responsive
 * ------------------------- */
@media (max-width:1100px){
  :root{ --left-w:260px; --right-w:360px; }
}

@media (max-width:920px){
  .layout{ grid-template-columns:1fr; }
  .left{ order:1; }
  .main{ order:2; }
  .right{ order:3; }
}
