/* ===== Custom Properties ===== */
:root {
  --bg: #0b0b0f;
  --surface: #111118;
  --card: #16161f;
  --card-hover: #1c1c28;
  --danger: #dc2626;
  --high: #ea580c;
  --medium: #d97706;
  --low: #16a34a;
  --safe: #22c55e;
  --accent: #f43f5e;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

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

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

button { cursor: pointer; font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ===== Views ===== */
.view { display: none; }
.view.active { display: flex; }

/* ===== INPUT VIEW ===== */
#input-view {
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  position: relative;
  background:
    radial-gradient(ellipse at top left, rgba(244,63,94,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(244,63,94,0.06) 0%, transparent 50%),
    var(--bg);
}

.input-container {
  width: 100%;
  max-width: 720px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  animation: fadeSlideUp 0.6s ease-out;
}

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

/* Logo */
.logo-section { text-align: center; }

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-accent { color: var(--accent); }

.tagline {
  font-size: 1.125rem;
  color: var(--text-secondary);
  font-weight: 300;
}

/* Textarea */
.textarea-wrapper {
  position: relative;
  width: 100%;
}

#tos-input {
  width: 100%;
  min-height: 350px;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#tos-input::placeholder { color: var(--text-muted); }
#tos-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244,63,94,0.15); }

/* Scanning state */
#tos-input.scanning {
  border-color: var(--danger);
  animation: borderPulse 1.5s ease-in-out infinite;
}

@keyframes borderPulse {
  0%, 100% { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(220,38,38,0.15); }
  50% { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(244,63,94,0.2); }
}

.scan-line {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 12px 12px 0 0;
  animation: scanDown 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scanDown {
  0% { top: 0; opacity: 0; }
  5% { opacity: 1; }
  95% { opacity: 1; }
  100% { top: calc(100% - 2px); opacity: 0; }
}

.hidden { display: none !important; }

/* Loading info */
.loading-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  animation: fadeSlideUp 0.3s ease-out;
}

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

.loading-subtext {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.elapsed-timer {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Buttons */
.buttons-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: #e11d48;
  box-shadow: 0 0 20px rgba(244,63,94,0.35);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

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

.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }

/* Example chips */
.example-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.chip-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.chip {
  padding: 0.375rem 0.875rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: all 0.2s;
  animation: fadeSlideUp 0.5s ease-out backwards;
}

.chip:nth-child(2) { animation-delay: 0.1s; }
.chip:nth-child(3) { animation-delay: 0.2s; }
.chip:nth-child(4) { animation-delay: 0.3s; }

.chip:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

.shortcut-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

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

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.875rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
  max-width: 380px;
}

.toast.success { border-left: 3px solid var(--safe); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

.toast.removing { animation: toastOut 0.3s ease-in forwards; }

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

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

/* ===== REPORT HEADER ===== */
.report-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(11,11,15,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; }

.logo-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  transition: opacity 0.2s;
}

.logo-btn:hover { opacity: 0.8; }

.header-logo-text { font-family: var(--font-display); font-weight: 700; }

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

.company-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.doc-type-badge {
  padding: 0.2rem 0.6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-right {
  display: flex;
  gap: 0.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .input-container { padding: 1.25rem; }
  .logo-text { font-size: 2rem; }
  #tos-input { min-height: 250px; }

  .report-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .header-center { order: 3; width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .buttons-row { flex-direction: column; }
  .btn { justify-content: center; }
  .example-chips { flex-direction: column; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
