/* ═══════════════════════════════════════════════════════════
   FRAMECRAFT — DESIGN SYSTEM & GLOBAL STYLES
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Color Palette */
  --bg-deepest:   #0d0d0f;
  --bg-base:      #111114;
  --bg-elevated:  #18181d;
  --bg-panel:     #1e1e26;
  --bg-surface:   #252530;
  --bg-hover:     #2e2e3a;
  --bg-active:    #35354a;

  --border-subtle:  rgba(255,255,255,0.06);
  --border-default: rgba(255,255,255,0.10);
  --border-strong:  rgba(255,255,255,0.18);

  --text-primary:   #f0f0f5;
  --text-secondary: #9090a8;
  --text-muted:     #5c5c72;
  --text-disabled:  #3a3a4a;

  /* Accent Colors */
  --accent:         #7c6cff;
  --accent-hover:   #9080ff;
  --accent-glow:    rgba(124, 108, 255, 0.25);

  /* Layer Colors */
  --layer-video:  #e94560;
  --layer-image:  #4caf89;
  --layer-audio:  #f5a623;
  --layer-text:   #5bc0de;

  /* Semantic */
  --danger:       #e94560;
  --danger-hover: #ff5573;
  --success:      #4caf89;
  --warning:      #f5a623;

  /* Layout */
  --toolbar-h:    52px;
  --timeline-h:   220px;
  --props-w:      240px;
  --labels-w:     240px;
  --media-lib-w:  220px;

  /* Typography */
  --font-ui:   'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Misc */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --shadow-md:  0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.7);
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-deepest);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* ── App Layout ── */
#app {
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr var(--timeline-h);
  grid-template-columns: 100%;
  height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

#app > * {
  min-width: 0;
  max-width: 100%;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb {
  background: var(--bg-active);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Buttons ── */
button {
  font-family: var(--font-ui);
  font-size: 11px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-btn {
  background: transparent;
  color: var(--text-secondary);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.icon-btn:active { transform: scale(0.95); }

/* ── Inputs ── */
input, select, textarea {
  font-family: var(--font-ui);
  font-size: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
select option { background: var(--bg-panel); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 260px;
  backdrop-filter: blur(12px);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ── Context Menu ── */
#context-menu {
  position: fixed;
  z-index: 9998;
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  animation: ctxIn 0.1s ease;
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.ctx-item {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
  font-size: 12px;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(233, 69, 96, 0.15); }
.ctx-sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* ── Properties Panel Common ── */
.panel-header {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-subtle);
}
.props-section {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.prop-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.prop-row.full { flex-direction: column; }
.prop-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.prop-field.wide { flex: 2; }
.prop-field label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}
.prop-input {
  width: 100%;
  padding: 4px 6px;
  height: 26px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.prop-select {
  width: 100%;
  padding: 4px 6px;
  height: 26px;
  cursor: pointer;
}
.prop-textarea {
  width: 100%;
  padding: 6px;
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}
.prop-color {
  width: 100%;
  height: 26px;
  padding: 2px;
  cursor: pointer;
}
.no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-muted);
  text-align: center;
  font-size: 11px;
}
.align-buttons {
  display: flex;
  gap: 4px;
}
.align-btn {
  flex: 1;
  padding: 5px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.align-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.align-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.layer-btn {
  flex: 1;
  padding: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
}
.layer-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.layer-btn.danger:hover { background: rgba(233, 69, 96, 0.15); color: var(--danger); border-color: var(--danger); }

/* ── Canvas Align Buttons ── */
.align-canvas-buttons {
  display: flex;
  gap: 3px;
  align-items: center;
}
.align-canvas-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
}
.align-canvas-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: scale(1.05);
}
.align-canvas-btn:active {
  transform: scale(0.95);
}
.align-divider {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 4px;
}

/* ── Undo/Redo disabled state ── */
.tb-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN (Media Queries)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  :root {
    --media-lib-w: 180px;
    --props-w: 200px;
    --labels-w: 120px;
  }
}

@media (max-width: 768px) {
  :root {
    --media-lib-w: 100%;
    --props-w: 100%;
  }

  html, body {
    overflow-y: auto;
  }

  #app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow-y: visible;
  }

  #workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  #canvas-area {
    min-height: 40vh;
    flex-shrink: 0;
  }

  #timeline-section {
    min-height: 300px;
    flex-shrink: 0;
  }
}
