/* ===== CSS Custom Properties ===== */
:root {
  --bg-primary: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #1a2236;
  --bg-input: #0d1321;
  --bg-surface: #161e2e;
  --accent-indigo: #818cf8;
  --accent-indigo-dim: rgba(129, 140, 248, 0.15);
  --accent-indigo-mid: rgba(129, 140, 248, 0.3);
  --accent-emerald: #34d399;
  --accent-emerald-dim: rgba(52, 211, 153, 0.15);
  --accent-amber: #fbbf24;
  --accent-amber-dim: rgba(251, 191, 36, 0.15);
  --accent-red: #f87171;
  --accent-red-dim: rgba(248, 113, 113, 0.15);
  --accent-blue: #60a5fa;
  --accent-blue-dim: rgba(96, 165, 250, 0.15);
  --accent-purple: #a78bfa;
  --accent-purple-dim: rgba(167, 139, 250, 0.15);
  --accent-gray: #9ca3af;
  --accent-gray-dim: rgba(156, 163, 175, 0.15);
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #1f2937;
  --border-light: #2d3748;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --transition-fast: 150ms ease;
  --transition-med: 250ms ease;
  --transition-slow: 400ms ease;
  --sidebar-width: 250px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.3;
}

a {
  color: var(--accent-indigo);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== App Shell ===== */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== View Transitions ===== */
.view {
  display: none;
  opacity: 0;
  transform: translateY(20px);
}

.view.active {
  display: flex;
  animation: fadeSlideUp var(--transition-slow) forwards;
}

@keyframes fadeSlideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Input View ===== */
.input-view {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.input-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 3rem;
  max-width: 720px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo h1 {
  font-size: 2.5rem;
  color: var(--accent-indigo);
  letter-spacing: 1px;
}

.logo .tagline {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-weight: 300;
}

.input-area {
  margin-bottom: 1.25rem;
}

.input-area textarea {
  width: 100%;
  min-height: 300px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 1.25rem;
  resize: vertical;
  line-height: 1.7;
  transition: border-color var(--transition-fast);
}

.input-area textarea::placeholder {
  color: var(--text-muted);
}

.input-area textarea:focus {
  outline: none;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px var(--accent-indigo-dim);
}

/* ===== Buttons ===== */
.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-indigo);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #6366f1;
  box-shadow: 0 0 16px var(--accent-indigo-dim);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.keyboard-hint {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.keyboard-hint kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ===== Loading State ===== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.loading-overlay.active {
  display: flex;
}

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

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

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

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: #fff;
  pointer-events: auto;
  animation: toastIn var(--transition-med) forwards;
  box-shadow: var(--shadow-md);
  max-width: 360px;
}

.toast.removing {
  animation: toastOut var(--transition-fast) forwards;
}

.toast-success { background: #065f46; border: 1px solid var(--accent-emerald); }
.toast-error   { background: #7f1d1d; border: 1px solid var(--accent-red); }
.toast-info    { background: #312e81; border: 1px solid var(--accent-indigo); }

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  color: #fff;
}

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

@keyframes toastOut {
  to { opacity: 0; transform: translateX(80px); }
}

/* ===== Floating Action Buttons ===== */
.fab-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 50;
}

.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}

.fab-new {
  background: var(--accent-indigo);
  color: #fff;
}

.fab-new:hover {
  background: #6366f1;
  transform: scale(1.1);
}

.fab-copy {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.fab-copy:hover {
  background: var(--bg-card-hover);
  transform: scale(1.1);
}

.fab-suggest {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.fab-suggest:hover {
  background: var(--bg-card-hover);
  transform: scale(1.1);
}

/* ===== Error State ===== */
.error-state {
  text-align: center;
  padding: 3rem 2rem;
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ===== Mobile Hamburger ===== */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .input-card {
    padding: 1.5rem;
  }

  .logo h1 {
    font-size: 2rem;
  }

  .input-area textarea {
    min-height: 220px;
    font-size: 0.8rem;
  }

  .btn {
    padding: 0.55rem 1rem;
    font-size: 0.82rem;
  }

  .btn-row {
    justify-content: center;
  }

  .hamburger-btn {
    display: flex;
  }

  .fab-container {
    bottom: 1rem;
    right: 1rem;
  }
}

@media (max-width: 480px) {
  .input-card {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .logo h1 {
    font-size: 1.7rem;
  }
}