/* ===================================================================
   Diagram Generation Platform — Minimal Light UI
   =================================================================== */

/* ── Design Tokens ──────────────────────────────────────────────── */
:root {
  --bg-base:        #f8fafc;
  --bg-surface:     #ffffff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #fdfdfd;
  --border:         #e2e8f0;
  --border-focus:   #cbd5e1;
  --accent:         #2563eb;
  --accent-light:   #eff6ff;
  --accent-hover:   #1d4ed8;
  
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --success:        #10b981;
  --success-light:  #ecfdf5;
  --error:          #ef4444;
  --error-light:    #fef2f2;
  --warning:        #f59e0b;

  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      16px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -4px rgba(0,0,0,0.05);

  --font-sans:      'Inter', system-ui, -apple-system, sans-serif;
  --font-display:   'Outfit', var(--font-sans);
  --font-mono:      'JetBrains Mono', monospace;

  --transition:     0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ── Header ─────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: var(--accent);
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.815rem;
  color: var(--text-secondary);
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #ffffff;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.815rem;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--success);
  opacity: 0.4;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}

/* ── Main Layout ─────────────────────────────────────────────────── */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header-simple {
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Upload Zone ─────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  background-color: var(--bg-base);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background-color: var(--accent-light);
}

.upload-icon-wrap {
  color: var(--accent);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.upload-zone:hover .upload-icon-wrap {
  transform: translateY(-2px);
}

.upload-title {
  font-weight: 600;
  font-size: 0.935rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-sub {
  font-size: 0.815rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.upload-constraints {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.upload-constraint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: #ffffff;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 9999px;
}

.upload-constraint svg {
  color: var(--text-muted);
}

/* Progress bar */
.upload-progress {
  margin-top: 20px;
  display: none;
}

.upload-progress.visible {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.815rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.progress-bar-track {
  height: 6px;
  background-color: var(--bg-base);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent);
  width: 0%;
  transition: width 0.15s ease-out;
}

/* ── Result Card / Output Area ───────────────────────────────────── */
.result-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge.pending {
  background-color: #fef3c7;
  color: #d97706;
}

.status-badge.running {
  background-color: var(--accent-light);
  color: var(--accent);
}

.status-badge.done {
  background-color: var(--success-light);
  color: var(--success);
}

.status-badge.failed {
  background-color: var(--error-light);
  color: var(--error);
}

.hidden {
  display: none !important;
}

/* Empty State */
.result-empty {
  padding: 64px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-empty-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.result-empty-title {
  font-weight: 600;
  font-size: 0.935rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.result-empty-sub {
  font-size: 0.815rem;
  color: var(--text-secondary);
  max-width: 280px;
}

/* Loading State */
.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-weight: 600;
  font-size: 0.935rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.loading-sub {
  font-size: 0.815rem;
  color: var(--text-secondary);
}

/* Error State */
.result-error {
  border: 1px solid var(--error);
  background-color: var(--error-light);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}

.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--error);
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 12px;
}

.error-log {
  font-family: var(--font-mono);
  font-size: 0.815rem;
  color: #7f1d1d;
  background-color: #ffffff;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 250px;
}

/* Success / Image Output Area */
.diagram-output-wrapper {
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  margin-bottom: 20px;
  min-height: 250px;
}

.diagram-preview-area {
  cursor: zoom-in;
  max-width: 100%;
}

.diagram-preview-area img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.diagram-preview-area img:hover {
  transform: scale(1.015);
}

.result-actions {
  display: flex;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.25);
}

/* ── Lightbox ────────────────────────────────────────────────────── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.lightbox-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-inner {
  width: 90vw;
  height: 90vh;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
}

.lightbox-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: #ffffff;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  border-bottom: 1px solid var(--border);
}

.lightbox-filename {
  font-weight: 600;
  font-size: 0.935rem;
  color: var(--text-primary);
}

.lightbox-actions {
  display: flex;
  gap: 12px;
}

.btn-lb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.815rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: 1px solid var(--border);
  background-color: #ffffff;
  color: var(--text-primary);
}

.btn-lb-download {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.btn-lb-download:hover {
  background-color: var(--accent-hover);
}

.btn-lb-close:hover {
  background-color: var(--bg-base);
}

.lightbox-img-wrap {
  flex: 1;
  background-color: var(--bg-base);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 32px;
}

.lightbox-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
}

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background-color: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  min-width: 250px;
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.info {
  border-left: 4px solid var(--accent);
}

.toast-icon {
  display: flex;
  align-items: center;
}

.toast-icon svg {
  width: 18px;
  height: 18px;
}

.toast.error .toast-icon svg { color: var(--error); }
.toast.success .toast-icon svg { color: var(--success); }
.toast.info .toast-icon svg { color: var(--accent); }

.toast-msg {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.toast.out {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateY(-12px); opacity: 0; }
}
