/* ============================================================
   API Doc Scraper — Design System
   Dark mode Glass morphism + vibrant purple-blue gradient
   ============================================================ */

   :root {
    /* Colors */
    --color-bg: #0a0a0f;
    --color-bg-2: #0f0f1a;
    --color-surface: rgba(255, 255, 255, 0.04);
    --color-surface-hover: rgba(255, 255, 255, 0.07);
    --color-border: rgba(255, 255, 255, 0.08);
    --color-border-focus: rgba(139, 92, 246, 0.5);
  
    --color-primary: #7c3aed;
    --color-primary-light: #8b5cf6;
    --color-secondary: #2563eb;
    --color-accent: #06b6d4;
  
    --color-text: #f0f0f5;
    --color-text-muted: #7b7b9a;
    --color-text-dim: #4a4a6a;
    --color-error: #f87171;
    --color-success: #34d399;
    --color-warning: #fbbf24;
  
    /* Gradients */
    --grad-primary: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
    --grad-glow: radial-gradient(circle at 50% 0%, rgba(124, 58, 237, 0.15) 0%, transparent 60%);
  
    /* Typography */
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
    /* Spacing & Shape */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
  
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* ============================================================
     Reset & Base
     ============================================================ */
  
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  html {
    scroll-behavior: smooth;
  }
  
  body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    background-image:
      var(--grad-glow),
      radial-gradient(circle at 80% 80%, rgba(37, 99, 235, 0.08) 0%, transparent 50%);
  }
  
  /* ============================================================
     Background Particles
     ============================================================ */
  
  .bg-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
  }
  
  .particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.12;
    animation: float linear infinite;
    background: var(--grad-primary);
    filter: blur(1px);
  }
  
  .particle:nth-child(1) { width: 3px; height: 3px; left: 15%; top: 20%; animation-duration: 18s; animation-delay: 0s; }
  .particle:nth-child(2) { width: 2px; height: 2px; left: 70%; top: 60%; animation-duration: 24s; animation-delay: -5s; }
  .particle:nth-child(3) { width: 4px; height: 4px; left: 40%; top: 80%; animation-duration: 20s; animation-delay: -8s; }
  .particle:nth-child(4) { width: 2px; height: 2px; left: 85%; top: 15%; animation-duration: 28s; animation-delay: -12s; }
  .particle:nth-child(5) { width: 3px; height: 3px; left: 30%; top: 45%; animation-duration: 22s; animation-delay: -3s; }
  
  @keyframes float {
    0%   { transform: translateY(0px) translateX(0px) rotate(0deg); }
    33%  { transform: translateY(-30px) translateX(15px) rotate(120deg); }
    66%  { transform: translateY(10px) translateX(-10px) rotate(240deg); }
    100% { transform: translateY(0px) translateX(0px) rotate(360deg); }
  }
  
  /* ============================================================
     Layout
     ============================================================ */
  
  .container {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  
  /* ============================================================
     Header
     ============================================================ */
  
  .header {
    text-align: center;
    padding: 20px 0 8px;
  }
  
  .logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
  }
  
  .logo-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    animation: pulse-glow 3s ease-in-out infinite;
  }
  
  @keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
    50%       { box-shadow: 0 0 20px 4px rgba(124, 58, 237, 0.3); }
  }
  
  .logo-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
  }
  
  .logo-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
  }
  
  .header-desc {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.7;
  }
  
  /* ============================================================
     Glass Card
     ============================================================ */
  
  .glass {
    background: var(--color-surface);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow:
      0 4px 40px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
  
  .card {
    padding: 36px;
    position: relative;
    overflow: hidden;
  }
  
  .card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.4), transparent);
    pointer-events: none;
  }
  
  /* ============================================================
     Form Section
     ============================================================ */
  
  .form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: -10px;
  }
  
  .input-group {
    position: relative;
    display: flex;
    align-items: center;
  }
  
  .input-icon {
    position: absolute;
    left: 16px;
    color: var(--color-text-dim);
    pointer-events: none;
    transition: color var(--transition-fast);
    z-index: 1;
  }
  
  .url-input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    outline: none;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal), background var(--transition-normal);
    caret-color: var(--color-primary-light);
  }
  
  .url-input::placeholder {
    color: var(--color-text-dim);
    font-family: var(--font-sans);
  }
  
  .url-input:focus {
    border-color: var(--color-border-focus);
    background: rgba(124, 58, 237, 0.05);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12), 0 0 20px rgba(124, 58, 237, 0.08);
  }
  
  .url-input:focus + .input-icon,
  .input-group:focus-within .input-icon {
    color: var(--color-primary-light);
  }
  
  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
  }
  
  .url-input.shake {
    animation: shake 0.5s ease;
    border-color: var(--color-error);
  }
  
  /* Advanced options */
  .advanced-options {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }
  
  .advanced-toggle {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: background var(--transition-fast);
  }
  
  .advanced-toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
  }
  
  .advanced-toggle::-webkit-details-marker { display: none; }
  
  .options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid var(--color-border);
  }
  
  .option-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  
  .option-field label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 500;
  }
  
  .option-field input {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast);
  }
  
  .option-field input:focus {
    border-color: var(--color-border-focus);
  }
  
  /* ============================================================
     Buttons
     ============================================================ */
  
  .btn-primary {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 28px;
    background: var(--grad-primary);
    color: white;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-normal);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
    letter-spacing: 0.2px;
  }
  
  .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.45);
  }
  
  .btn-primary:active {
    transform: translateY(0);
  }
  
  .btn-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
  }
  
  .btn-primary:hover .btn-shine {
    transform: translateX(100%);
  }
  
  .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
  }
  
  .btn-secondary:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: rgba(255, 255, 255, 0.15);
  }
  
  /* ============================================================
     Progress Section
     ============================================================ */
  
  .progress-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }
  
  .progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .progress-status {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  
  .progress-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
  }
  
  /* Spinner */
  .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-top-color: var(--color-primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  .stat-badge {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 4px 12px;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    color: var(--color-primary-light);
    font-weight: 500;
  }
  
  /* Progress bar */
  .progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
  }
  
  .progress-bar {
    height: 100%;
    background: var(--grad-primary);
    border-radius: 10px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
  }
  
  .progress-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: progress-shimmer 1.5s infinite;
  }
  
  @keyframes progress-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
  }
  
  .current-url-display {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--color-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
  }
  
  /* Terminal log */
  .log-terminal {
    background: #050508;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    overflow: hidden;
  }
  
  .terminal-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
  }
  .dot-red    { background: #ff5f57; }
  .dot-yellow { background: #febc2e; }
  .dot-green  { background: #28c840; }
  
  .terminal-title {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--color-text-dim);
    margin-left: 4px;
  }
  
  .log-lines {
    max-height: 280px;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
  }
  
  .log-lines::-webkit-scrollbar { width: 4px; }
  .log-lines::-webkit-scrollbar-track { background: transparent; }
  .log-lines::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
  
  .log-line {
    display: flex;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.5;
    animation: fadeInUp 0.2s ease;
  }
  
  @keyframes fadeInUp {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  
  .log-ts {
    color: var(--color-text-dim);
    flex-shrink: 0;
    user-select: none;
  }
  
  .log-msg { color: #b0b0cc; }
  .log-error .log-msg { color: var(--color-error); }
  .log-warning .log-msg { color: var(--color-warning); }
  
  /* ============================================================
     Result Section
     ============================================================ */
  
  .result-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    text-align: center;
  }
  
  .result-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  
  .success-icon {
    font-size: 3rem;
    animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  @keyframes pop-in {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
  }
  
  .result-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  
  .result-desc {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--color-text-muted);
  }
  
  .result-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .result-actions .btn-primary {
    min-width: 220px;
  }
  
  /* ============================================================
     Files Section
     ============================================================ */
  
  .files-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .files-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
  }
  
  .files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .files-empty {
    color: var(--color-text-dim);
    font-size: 0.85rem;
    font-style: italic;
    padding: 8px 0;
  }
  
  .file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), border-color var(--transition-fast);
    gap: 12px;
  }
  
  .file-item:hover {
    background: var(--color-surface-hover);
    border-color: rgba(255, 255, 255, 0.12);
  }
  
  .file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  
  .file-icon { font-size: 1rem; flex-shrink: 0; }
  
  .file-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .file-size {
    font-size: 0.75rem;
    color: var(--color-text-dim);
    flex-shrink: 0;
  }
  
  .btn-file-dl {
    font-size: 0.8rem;
    padding: 7px 14px;
    background: rgba(124, 58, 237, 0.1);
    color: var(--color-primary-light);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-sm);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    font-weight: 500;
  }
  
  .btn-file-dl:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
  }
  
  /* ============================================================
     Footer
     ============================================================ */
  
  .footer {
    text-align: center;
    color: var(--color-text-dim);
    font-size: 0.75rem;
  }
  
  /* ============================================================
     Utility
     ============================================================ */
  
  .hidden {
    display: none !important;
  }
  
  /* ============================================================
     Responsive
     ============================================================ */
  
  @media (max-width: 520px) {
    .container { padding: 20px 12px 40px; }
    .card { padding: 24px 18px; }
    .logo-title { font-size: 1.4rem; }
    .options-grid { grid-template-columns: 1fr; }
    .result-actions { flex-direction: column; }
    .file-item { flex-direction: column; align-items: flex-start; }
  }
