/* ============================================================
   Tech Blog Post Outline Builder — Styles
   Theme: Clean writing tool / document editor aesthetic
   Primary: Blue #2563eb
   ============================================================ */

:root {
  --c-primary: #2563eb;
  --c-primary-light: #3b82f6;
  --c-primary-dim: rgba(37, 99, 235, 0.08);
  --c-primary-ring: rgba(37, 99, 235, 0.25);
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-surface-2: #f1f5f9;
  --c-border: #e2e8f0;
  --c-border-hover: #cbd5e1;
  --c-text: #1e293b;
  --c-text-dim: #475569;
  --c-text-muted: #94a3b8;
  --c-success: #16a34a;
  --c-danger: #dc2626;
  --c-danger-dim: rgba(220, 38, 38, 0.08);
  --c-warning: #d97706;
  --radius: 10px;
  --radius-sm: 6px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-content: 'Georgia', serif;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --transition: 200ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
}

::selection { background: var(--c-primary-dim); color: var(--c-primary); }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ---------- Header ---------- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-group { display: flex; align-items: center; gap: 0.5rem; }

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--c-primary-dim);
  color: var(--c-primary);
}

h1 { font-size: 1.1rem; font-weight: 700; color: var(--c-text); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 9px;
  background: var(--c-primary);
  color: #fff;
}

/* ---------- Main ---------- */
#app-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- Panel Card ---------- */
.panel-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.panel-card h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.panel-title-row h2 { margin-bottom: 0; }

.hidden { display: none !important; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.span-2 { grid-column: span 2; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-muted);
}

.text-input, .select-input {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.text-input:focus, .select-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-ring);
  outline: none;
}

.textarea { resize: vertical; font-family: var(--font-ui); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-ui);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--c-primary-light); transform: translateY(-1px); box-shadow: 0 3px 12px var(--c-primary-ring); }

.btn-outline {
  background: transparent;
  color: var(--c-text-dim);
  border: 1px solid var(--c-border);
}
.btn-outline:hover { border-color: var(--c-primary); color: var(--c-primary); background: var(--c-primary-dim); }

.btn-ghost {
  background: transparent;
  color: var(--c-text-dim);
}
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }

.btn-danger:hover { color: var(--c-danger); background: var(--c-danger-dim); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

.stat-badge {
  padding: 0.2rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
}

.action-group { display: flex; gap: 0.35rem; }

/* ---------- Sections ---------- */
.sections-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.section-item {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: grab;
  transition: all var(--transition);
  animation: fadeSlideIn 300ms ease;
}
.section-item:hover { border-color: var(--c-border-hover); }
.section-item.dragging { opacity: 0.5; border-color: var(--c-primary); }
.section-item.drag-over { border-color: var(--c-primary); background: var(--c-primary-dim); }

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drag-handle {
  color: var(--c-text-muted);
  cursor: grab;
  flex-shrink: 0;
  font-size: 14px;
}

.section-type-badge {
  padding: 0.15rem 0.4rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
  flex-shrink: 0;
}
.section-type-badge.introduction { background: #dbeafe; color: #1d4ed8; }
.section-type-badge.concept { background: #e0e7ff; color: #4338ca; }
.section-type-badge.code { background: #dcfce7; color: #15803d; }
.section-type-badge.diagram { background: #fef3c7; color: #b45309; }
.section-type-badge.summary { background: #f3e8ff; color: #7c3aed; }
.section-type-badge.reading { background: #fce7f3; color: #be185d; }
.section-type-badge.cta { background: #ffe4e6; color: #be123c; }

.section-title-input {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-content);
  color: var(--c-text);
  background: transparent;
  transition: border-color var(--transition);
}
.section-title-input:focus {
  border-color: var(--c-border);
  outline: none;
}

.section-note {
  padding: 0.3rem 0.5rem;
  border: 1px dashed var(--c-border);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  color: var(--c-text-dim);
  background: var(--c-surface-2);
  resize: none;
}
.section-note::placeholder { color: var(--c-text-muted); }

.btn-remove-section {
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 1rem;
  transition: color var(--transition);
}
.btn-remove-section:hover { color: var(--c-danger); }

/* ---------- Action Bar ---------- */
.action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- Drawer ---------- */
.saved-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
}

.drawer-content {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(400px, 90vw);
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: slideIn 250ms ease;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-header h2 {
  margin-bottom: 0;
  color: var(--c-text);
  font-size: 1rem;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.saved-item {
  padding: 0.75rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.saved-item:hover { border-color: var(--c-primary); background: var(--c-primary-dim); }

.saved-item-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.15rem;
}

.saved-item-meta {
  font-size: 0.6875rem;
  color: var(--c-text-muted);
}

.saved-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  padding: 0.6rem 1rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  box-shadow: var(--shadow);
  animation: fadeSlideIn 250ms ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--c-success); }
.toast.error { border-left: 3px solid var(--c-danger); }

/* ---------- Animations ---------- */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .action-bar { flex-direction: column; }
}
