/* ============================================================
   Animation Keyframe Exporter — Timeline Blue Dark Theme
   ============================================================ */

:root {
  --primary: #3B82F6;
  --primary-dim: rgba(59, 130, 246, 0.15);
  --secondary: #60A5FA;
  --accent: #F59E0B;
  --accent-dim: rgba(245, 158, 11, 0.15);
  --bg: #0B1220;
  --bg-card: #111827;
  --bg-surface: #1E293B;
  --bg-input: #0F172A;
  --border: rgba(59, 130, 246, 0.15);
  --border-hover: rgba(59, 130, 246, 0.35);
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.header {
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.4rem; }
.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-accent, .btn-add, .btn-play {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { box-shadow: 0 0 15px rgba(59, 130, 246, 0.4); transform: translateY(-1px); }

.btn-secondary { background: var(--bg-card); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-hover); }

.btn-accent { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-accent:hover { box-shadow: 0 0 15px rgba(245, 158, 11, 0.4); transform: translateY(-1px); }

.btn-add { background: var(--primary-dim); color: var(--primary); border-color: transparent; padding: 6px 12px; font-size: 0.78rem; }
.btn-add:hover { background: rgba(59, 130, 246, 0.25); }

.btn-play {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-play:hover { box-shadow: var(--glow); transform: scale(1.05); }

.btn-remove {
  width: 24px;
  height: 24px;
  background: rgba(239, 68, 68, 0.15);
  border: none;
  border-radius: 4px;
  color: #EF4444;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}

.btn-remove:hover { background: rgba(239, 68, 68, 0.3); }

/* Inputs */
.select-input, .text-input, .num-input {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition);
}

.select-input:focus, .text-input:focus, .num-input:focus { border-color: var(--primary); }
.num-input { width: 72px; }
.text-input { width: 130px; }
.color-input { width: 32px; height: 28px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; background: none; padding: 0; }

/* Controls Bar */
.controls-bar {
  max-width: 1300px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.control-group { display: flex; flex-direction: column; gap: 4px; }
.control-group.small { flex-direction: row; align-items: center; gap: 6px; }
.control-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.unit { font-size: 0.75rem; color: var(--text-muted); margin-left: -2px; }

/* Workspace */
.main { flex: 1; max-width: 1300px; width: 100%; margin: 0 auto; }

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 20px;
}

/* Preview Panel */
.preview-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-header, .editor-header, .timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }

.preview-stage {
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1E293B;
  position: relative;
  overflow: hidden;
}

.preview-element {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow);
}

/* Editor Panel */
.editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 310px;
  display: flex;
  flex-direction: column;
}

.keyframes-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.keyframe-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.keyframe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.keyframe-percent {
  display: flex;
  align-items: center;
  gap: 6px;
}

.keyframe-percent input {
  width: 52px;
  padding: 4px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  outline: none;
}

.keyframe-percent input:focus { border-color: var(--accent); }
.keyframe-percent span { font-size: 0.75rem; color: var(--text-muted); }

.keyframe-easing {
  display: flex;
  align-items: center;
  gap: 4px;
}

.keyframe-easing select {
  padding: 3px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  outline: none;
}

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

.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prop-row select {
  width: 100px;
  padding: 4px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  outline: none;
}

.prop-row input[type="text"] {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  outline: none;
}

.prop-row input:focus, .prop-row select:focus { border-color: var(--primary); }

.btn-add-prop {
  padding: 3px 8px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-add-prop:hover { border-color: var(--primary); color: var(--primary); }

/* Timeline */
.timeline-section {
  padding: 0 20px 24px;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

.timeline {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
}

.timeline-track {
  height: 40px;
  background: var(--bg-surface);
  border-radius: 6px;
  position: relative;
  cursor: pointer;
}

.timeline-playhead {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  left: 0%;
  transition: left 0.05s linear;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
  pointer-events: none;
  z-index: 5;
}

.timeline-markers {
  display: flex;
  justify-content: space-between;
  padding: 6px 0 0;
}

.timeline-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid var(--secondary);
  border-radius: 50%;
  cursor: grab;
  z-index: 10;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.timeline-marker:hover { transform: translate(-50%, -50%) scale(1.3); box-shadow: var(--glow); }
.timeline-marker.active { background: var(--accent); border-color: var(--accent); }

.timeline-tick {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 540px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body { padding: 20px; }

.code-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 12px;
  outline: none;
  resize: vertical;
}

.code-textarea:focus { border-color: var(--primary); }

.code-output {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 14px;
  overflow-x: auto;
  white-space: pre;
  max-height: 350px;
  overflow-y: auto;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
  .workspace { grid-template-columns: 1fr; }
  .header-content { flex-direction: column; align-items: flex-start; }
  .controls-bar { flex-wrap: wrap; gap: 10px; }
  .preview-stage { height: 200px; }
}

@media (max-width: 480px) {
  .header-actions { flex-wrap: wrap; }
  .controls-bar { padding: 10px 12px; }
  .main { padding: 0; }
  .workspace { padding: 12px; gap: 12px; }
  .timeline-section { padding: 0 12px 16px; }
}
