/* ==========================================================================
   Design Tokens & CSS Variables
   ========================================================================== */
:root {
  /* Color Palette - Dark Theme Default */
  --bg-primary: #0a0b10;
  --bg-secondary: #12141c;
  --bg-tertiary: #1b1e2b;
  --bg-card: rgba(22, 25, 38, 0.75);
  --bg-card-hover: rgba(28, 32, 48, 0.9);
  --bg-input: rgba(15, 17, 26, 0.8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(129, 140, 248, 0.4);
  --border-color-active: rgba(99, 102, 241, 0.8);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Vibrant Accents */
  --accent-primary: #6366f1;       /* Indigo */
  --accent-secondary: #8b5cf6;     /* Purple */
  --accent-cyan: #06b6d4;          /* Cyan */
  --accent-emerald: #10b981;       /* Success */
  --accent-rose: #f43f5e;          /* Warning/Error */
  
  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --gradient-glow: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(217, 70, 239, 0.15));
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.35);
  --shadow-glow-cyan: 0 0 24px rgba(6, 182, 212, 0.3);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --backdrop-blur: blur(16px);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-input: #ffffff;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(99, 102, 241, 0.5);
  --border-color-active: rgba(79, 70, 229, 0.8);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.2);
  --gradient-glow: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(217, 70, 239, 0.08));
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 100%);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Background Atmosphere Glows */
.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}

.bg-glow-1 {
  top: -150px;
  left: 10%;
  background: radial-gradient(circle, #6366f1 0%, rgba(99, 102, 241, 0) 70%);
}

.bg-glow-2 {
  bottom: 5%;
  right: 5%;
  background: radial-gradient(circle, #d946ef 0%, rgba(217, 70, 239, 0) 70%);
}

/* Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 32px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.logo-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Theme Toggle Button */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: var(--backdrop-blur);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* ==========================================================================
   Glass Cards & Common Components
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--gradient-brand);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-glow {
  position: relative;
}

.btn-glow::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--gradient-brand);
  filter: blur(8px);
  z-index: -1;
  opacity: 0.4;
  transition: opacity var(--transition-normal);
}

.btn-glow:hover::after {
  opacity: 0.7;
}

/* ==========================================================================
   Upload Section & Drag and Drop
   ========================================================================== */
.upload-section {
  padding: 40px;
  margin-bottom: 24px;
  position: relative;
  background-image: var(--gradient-card);
}

.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  background: rgba(99, 102, 241, 0.02);
  transition: all var(--transition-normal);
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.06);
  transform: scale(1.005);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.1);
}

.dropzone.dragover {
  border-style: solid;
}

.file-input-hidden {
  display: none;
}

.dropzone-icon-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.15);
  transition: transform var(--transition-smooth);
}

.dropzone:hover .dropzone-icon-circle {
  transform: translateY(-4px) scale(1.05);
}

.dropzone-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.dropzone-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.dropzone-desc code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: var(--accent-cyan);
}

.dropzone-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.dropzone-features {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.feature-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Settings Accordion */
.settings-details {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.settings-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.settings-summary:hover {
  color: var(--text-primary);
}

.settings-body {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 24px;
}

.setting-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.setting-checkbox input {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ==========================================================================
   Processing / Loading Section
   ========================================================================== */
.processing-section {
  padding: 60px 24px;
  text-align: center;
  margin-bottom: 24px;
}

.processing-content {
  max-width: 440px;
  margin: 0 auto;
}

.spinner-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  animation: spin 0.8s linear infinite;
}

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

.processing-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.processing-status {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
  transition: width 0.2s ease;
}

.progress-percent {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* ==========================================================================
   Results Dashboard
   ========================================================================== */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.result-card {
  padding: 28px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.result-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.result-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
}

.result-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.stat-pill {
  background: var(--bg-tertiary);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   File Explorer & Viewer
   ========================================================================== */
.explorer-card {
  padding: 0;
}

.explorer-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 520px;
}

/* Left Pane: Tree View */
.file-tree-pane {
  background: rgba(15, 17, 26, 0.5);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .file-tree-pane {
  background: rgba(241, 245, 249, 0.7);
}

.pane-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.pane-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
}

.file-tree {
  padding: 10px 8px;
  overflow-y: auto;
  max-height: 580px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-folder-group {
  margin-bottom: 4px;
}

.tree-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.tree-folder-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.tree-folder-items {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tree-file-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.tree-file-item.active {
  background: rgba(99, 102, 241, 0.18);
  color: #fff;
  font-weight: 500;
}

.tree-file-name {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-file-icon {
  flex-shrink: 0;
  font-size: 0.9em;
}

.tree-file-size {
  font-size: 0.6875rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Right Pane: File Viewer */
.file-viewer-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.viewer-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.viewer-filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.viewer-filemeta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 10px;
}

.viewer-actions {
  display: flex;
  gap: 8px;
}

.viewer-body {
  flex: 1;
  overflow: auto;
  position: relative;
  max-height: 580px;
}

/* Code Viewer */
.code-viewer-container {
  padding: 18px 22px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.code-viewer-container pre {
  margin: 0;
}

/* Image Viewer */
.image-viewer-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  min-height: 400px;
  background-image: 
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 20px 20px;
}

.image-preview-wrapper {
  max-width: 90%;
  max-height: 460px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.image-preview-wrapper img {
  display: block;
  max-width: 100%;
  max-height: 460px;
  object-fit: contain;
}

/* Binary Viewer */
.binary-viewer-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.binary-info-card {
  text-align: center;
  color: var(--text-secondary);
}

.binary-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ==========================================================================
   Live Site Preview Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-dialog {
  width: 100%;
  max-width: 1240px;
  height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.modal-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title {
  font-weight: 700;
  font-size: 0.9375rem;
}

.modal-subtitle {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.device-switcher {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.device-btn {
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.device-btn:hover {
  color: var(--text-primary);
}

.device-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--accent-rose);
}

.modal-iframe-container {
  flex: 1;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 12px;
}

.modal-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  border-radius: var(--radius-sm);
  transition: width var(--transition-normal);
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .explorer-layout {
    grid-template-columns: 1fr;
  }
  .file-tree-pane {
    max-height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .upload-section {
    padding: 20px;
  }
  .dropzone {
    padding: 36px 16px;
  }
  .result-header {
    flex-direction: column;
  }
  .result-actions {
    width: 100%;
  }
  .result-actions .btn {
    flex: 1;
  }
}
