/* SOSParser - Ultra Dark Condensed Theme */

:root {
  --bg-primary: #050810;
  --bg-secondary: #0a0e17;
  --bg-tertiary: #0f141f;
  --bg-hover: #141925;
  
  --accent-primary: #00d9ff;
  --accent-secondary: #ff9500;
  --accent-tertiary: #00b8d4;
  
  --text-primary: #e8eaed;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-color: #1f2937;
  --border-accent: #00d9ff;
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.8);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* Header - Condensed */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title-section h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.title-section {
  text-decoration: none;
}

.title-section:hover h1 {
  color: var(--accent-secondary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
}

.format-support {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 500;
  margin: 0.3rem 0 0 0;
  opacity: 0.9;
}

/* Main Content - Centered */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

/* Upload Card - Centered */
.upload-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 600px;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-size: 0.9375rem;
  text-align: center;
}

.file-input-wrapper {
  position: relative;
}

.file-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.file-input-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2.5rem;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-input-display:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
}

.file-icon {
  font-size: 2rem;
}

.file-text {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
}

.help-text {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Form Actions */
.form-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-tertiary) 100%);
  color: var(--bg-primary);
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-link:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--bg-hover);
}

.icon-svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Info Panel - Simplified */
.info-panel {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.info-panel p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin: 0;
}

/* Flash Messages */
.flash-messages {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 1rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border-left: 3px solid;
  font-size: 0.875rem;
}

.flash-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.flash-info {
  background: rgba(0, 217, 255, 0.1);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 1rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: auto;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.version-checker {
  font-size: 0.8rem;
}

.version-status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.version-current {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
}

.version-outdated {
  color: #ff9800;
  background: rgba(255, 152, 0, 0.1);
  animation: pulse-warning 2s ease-in-out infinite;
  text-decoration: none;
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.version-outdated:hover {
  background: rgba(255, 152, 0, 0.2);
  transform: translateY(-1px);
}

.version-unknown {
  color: var(--text-muted);
  opacity: 0.7;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    gap: 1rem;
    align-items: center;
  }
  
  .footer-content > span:not(:last-child)::after {
    content: '|';
    margin-left: 1rem;
    color: var(--border-color);
  }
}

/* Upload Progress Overlay */
.upload-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 16, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.upload-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  overflow-y: auto;
}

.upload-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.upload-icon {
  font-size: 2rem;
}

.upload-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
}

/* Progress Bar */
.upload-progress-container {
  margin-bottom: 1.5rem;
}

.upload-progress-bar {
  height: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-tertiary) 100%);
  border-radius: 6px;
  transition: width 0.3s ease;
  position: relative;
}

.upload-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.upload-progress-fill.analyzing {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { 
    box-shadow: 0 0 10px var(--accent-primary), 0 0 20px rgba(0, 217, 255, 0.3);
  }
  50% { 
    box-shadow: 0 0 20px var(--accent-primary), 0 0 40px rgba(0, 217, 255, 0.5);
  }
}

.upload-progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}

#upload-percentage {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
}

#upload-speed {
  font-size: 0.875rem;
  color: var(--accent-secondary);
  font-weight: 600;
}

/* Upload Stats */
.upload-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.upload-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* Upload Status */
.upload-status {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  min-height: 1.25rem;
}

/* Cancel Button */
.btn-cancel {
  display: block;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Console Panel */
.console-container {
  margin: 1.5rem 0;
  display: none;
}

.console-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.console-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.console-toggle-icon {
  font-size: 0.625rem;
  transition: transform 0.2s ease;
}

.console-panel {
  display: none;
  margin-top: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: #0c0c0c;
}

.console-panel.expanded {
  display: block;
}

.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: #1a1a1a;
  border-bottom: 1px solid var(--border-color);
}

.console-title {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.console-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.875rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.console-clear:hover {
  opacity: 1;
  color: var(--text-primary);
}

.console-output {
  height: 280px;
  overflow-y: auto;
  padding: 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.console-line {
  padding: 0.125rem 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.console-default {
  color: #b0b0b0;
}

.console-info {
  color: var(--accent-primary);
}

.console-success {
  color: var(--success);
}

.console-error {
  color: var(--error);
}

.console-warning {
  color: var(--warning);
}

/* Console scrollbar */
.console-output::-webkit-scrollbar {
  width: 8px;
}

.console-output::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.console-output::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.console-output::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* Legacy spinner for backwards compatibility */
.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.report-browser {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 340px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.report-browser.active {
  transform: translateX(0);
}

.browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.browser-header h3 {
  margin: 0;
  color: var(--accent-primary);
}

.browser-subtitle {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin: 0.15rem 0 0 0;
}

.browser-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 8500;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.report-list {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.report-row {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.report-info {
  min-width: 0;
  flex: 1 1 auto;
}

.report-token {
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
}

.report-meta {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.report-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.btn-link.danger {
  color: var(--error);
}

.browser-empty,
.browser-loading,
.browser-error {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .title-section h1 {
    font-size: 1.5rem;
  }
  
  .upload-card {
    padding: 1.5rem;
    margin: 0 1rem;
  }
  
  main {
    padding: 1rem 0;
    align-items: flex-start;
  }
  
  .file-input-display {
    padding: 2rem 1rem;
  }
}

/* ─── SAR Selector ───────────────────────────────────────────────── */
/* SAR selector inside the upload overlay */
#sar-selector {
  width: 100%;
  margin-top: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.sar-selector-header {
  padding: 0.875rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sar-selector-header h3 {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.sar-selector-desc {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.sar-file-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.sar-file-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border-color);
}

.sar-file-item:last-child {
  border-bottom: none;
}

.sar-file-item:hover {
  background: var(--bg-hover);
}

.sar-file-item input[type=checkbox] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-primary);
  flex-shrink: 0;
  cursor: pointer;
}

.sar-file-name {
  flex: 1;
  font-size: 0.8125rem;
  font-family: monospace;
  color: var(--text-primary);
}

.sar-file-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sar-perf-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: color-mix(in srgb, #f59e0b 10%, var(--bg-secondary));
  border-top: 1px solid color-mix(in srgb, #f59e0b 30%, var(--border-color));
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.sar-perf-icon {
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.sar-selector-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-wrap: wrap;
}

.btn-sar-secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  transition: all 0.15s;
}

.btn-sar-secondary:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.sar-selector-actions .btn-primary {
  margin-left: auto;
  padding: 0.375rem 1.25rem;
  font-size: 0.875rem;
}
