/* CSS Custom Properties for Unified Design System */
:root {
  --bg-primary: #070a13;
  --bg-secondary: #0f1423;
  --bg-card: rgba(18, 24, 43, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(6, 182, 212, 0.2);
  
  --color-text-main: #f3f4f6;
  --color-text-muted: #9ca3af;
  
  --neon-cyan: #06b6d4;
  --neon-purple: #8b5cf6;
  --neon-green: #10b981;
  --neon-red: #ef4444;
  --neon-orange: #f59e0b;
  
  --neon-gradient: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glass-blur: blur(12px);
  
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Outfit', sans-serif;
}

/* Reset and Core Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--color-text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

/* App Container */
.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--card-shadow);
}

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

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 182, 212, 0.1);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(6, 182, 212, 0.3);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--neon-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--color-text-muted);
  display: block;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
  animation: pulse 2s infinite;
}

.status-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: #10b981;
}

/* Editor Layout Grid */
.editor-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  flex-grow: 1;
}

@media (max-width: 1024px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
}

/* Card Styling */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header .icon {
  font-size: 1.3rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.preview-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--neon-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.card-body {
  padding: 24px;
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.flex-grow {
  flex-grow: 1;
}

/* Left Panel: Preview Workspace */
.preview-panel {
  display: flex;
  flex-direction: column;
}

.video-workspace {
  background-color: rgba(5, 7, 14, 0.9);
  flex-grow: 1;
  position: relative;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* Upload Zone */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  cursor: pointer;
  width: 100%;
  height: 100%;
  transition: all 0.3s ease;
}

.upload-zone:hover {
  background: rgba(6, 182, 212, 0.03);
  border-color: var(--neon-cyan);
}

.upload-graphic {
  color: var(--color-text-muted);
  margin-bottom: 20px;
  transition: transform 0.3s ease;
}

.upload-zone:hover .upload-graphic {
  transform: translateY(-8px);
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.4));
}

.upload-zone h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

/* Canvas Display */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#render-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.overlay-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
}

.render-status {
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

/* Media Controls Bar */
.media-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(10, 14, 26, 0.85);
  border-top: 1px solid var(--border-color);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--color-text-main);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--neon-cyan);
  transform: scale(1.08);
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
}

.time-display {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  min-width: 45px;
}

.timeline {
  flex-grow: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.timeline-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--neon-gradient);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

/* Right Panel: Settings and Actions */
.setting-group {
  margin-bottom: 24px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.setting-header label {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text-main);
}

.setting-value {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--neon-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(6, 182, 212, 0.15);
}

.range-info {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 6px;
}

/* Custom Sliders */
.custom-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neon-cyan);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.8);
  transition: transform 0.1s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Color Preview Bar */
.color-preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.color-dot.red { background-color: var(--neon-red); box-shadow: 0 0 8px var(--neon-red); }
.color-dot.green { background-color: var(--neon-green); box-shadow: 0 0 8px var(--neon-green); }
.color-dot.blue { background-color: #3b82f6; box-shadow: 0 0 8px #3b82f6; }

.shift-formula {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Speed Graph */
.graph-card {
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.speed-indicator-badge {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  color: var(--neon-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.graph-container {
  flex-grow: 1;
  position: relative;
  min-height: 150px;
  margin: 10px 20px 20px 20px;
}

#speed-graph {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Action and Buttons */
.file-details {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-row .lbl {
  color: var(--color-text-muted);
}

.detail-row .val {
  font-weight: 500;
  max-width: 200px;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px 28px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  background: var(--neon-gradient);
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.6);
}

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

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

.glow-btn .btn-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.glow-btn:hover .btn-glow {
  opacity: 1;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  animation: pulse-border 2s infinite;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

/* Processing Loader Overlay */
.processing-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 19, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  gap: 16px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(6, 182, 212, 0.15);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

.loader-text {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
}

.loader-percentage {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  background: var(--neon-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Download & success state */
.download-section {
  margin-top: 16px;
  animation: fadeIn 0.4s ease;
}

.success-message {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--neon-green);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  justify-content: center;
}

/* Footer Styling */
.app-footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border-color);
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* Keyframes and Animations */
@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes pulse-border {
  0% {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 4px 25px rgba(16, 185, 129, 0.7);
  }
  100% {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  }
}

/* Waveform Labels styling */
.waveform-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-main);
  margin-bottom: 4px;
}

.waveform-sub {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Fingerprint Group Styles */
.fingerprint-group {
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.fingerprint-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neon-cyan);
  margin-bottom: 6px;
}
.fingerprint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  margin-bottom: 4px;
}
.fingerprint-row:last-child {
  margin-bottom: 0;
}
.lbl-small {
  color: var(--color-text-muted);
}
.val-mono {
  font-family: monospace;
  font-size: 0.68rem;
  color: var(--color-text-main);
  word-break: break-all;
  max-width: 75%;
  text-align: right;
}
.val-normal {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--color-text-main);
}

/* Forensic Identity Comparison Table Styles */
.identity-table th {
  text-transform: uppercase;
  letter-spacing: 1px;
}
.identity-table th, .identity-table td {
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.5px;
}
.identity-table tr:hover {
  background: rgba(6, 182, 212, 0.02);
}
.identity-table td {
  transition: all 0.25s ease;
}
.identity-table tr:last-child td {
  border-bottom: none;
}

/* Mobile & Tablet Ultra-Responsive Styles (Touch-Friendly Optimization) */
@media (max-width: 1024px) {
  .editor-layout {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 12px !important;
    gap: 16px !important;
  }

  .app-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 14px !important;
  }

  .status-indicator {
    width: 100% !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 8px !important;
  }

  .status-indicator a {
    margin-right: 8px !important;
    font-size: 0.75rem !important;
  }

  .editor-layout {
    display: flex !important;
    flex-direction: column !important;
  }

  .card {
    padding: 16px !important;
    border-radius: 12px !important;
  }

  .btn {
    padding: 14px 20px !important;
    font-size: 0.9rem !important;
    min-height: 48px !important;
  }

  .upload-zone {
    padding: 24px 16px !important;
  }

  .video-workspace {
    margin: 8px 0 !important;
  }

  .identity-table th, .identity-table td {
    padding: 8px 10px !important;
    font-size: 0.75rem !important;
    white-space: nowrap;
  }

  .preview-panel {
    display: flex !important;
    flex-direction: column !important;
  }

  .controls-panel {
    order: 2 !important;
  }

  /* Move Identity & Frequency Fingerprint Card to the absolute bottom on Mobile */
  #identity-card-wrapper {
    order: 99999 !important;
    margin-top: 16px !important;
  }

  .app-footer {
    padding: 16px 8px !important;
    font-size: 0.75rem !important;
    text-align: center !important;
  }
}

@media (max-width: 480px) {
  .logo-text h1 {
    font-size: 1.3rem !important;
  }

  .logo-text span {
    font-size: 0.65rem !important;
  }

  .card-header h2 {
    font-size: 1rem !important;
  }

  .setting-label {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
}
