/* ==========================================================================
   Variables
   Description: Global variables, colors, and theme definitions.
   ========================================================================== */
:root {
  /* Brand Colors */
  --bg-app: #080319;
  --surface-card: #0f0b29;
  --surface-hover: #1a1535;
  --bg-card: #0f0b29;
  /* Added for consistency with modal usage */

  --primary: #612fc9;
  /* Purple */
  --primary-hover: #4e24a3;
  --primary-glow: rgba(97, 47, 201, 0.4);

  --accent: #51c0b4;
  /* Teal */
  --accent-hover: #3da89c;

  --text-main: #ffffff;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(97, 47, 201, 0.5);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Reset
   Description: Base resets and typography.
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: "Google Sans Flex", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(circle at 15% 50%, rgba(97, 47, 201, 0.08), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(81, 192, 180, 0.05), transparent 25%);
  overflow-x: hidden;
}

button,
.btn,
.size-btn,
.tab {
  font-family: inherit !important;
}

#app-scale {
  zoom: 1.1;
}

/* ==========================================================================
   Layout
   Description: Core layout structure (Container, Header, Footer).
   ========================================================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* Header */
header {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
  background: rgba(8, 3, 25, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

/* Footer */
.footer {
  margin-top: auto;
  padding: 48px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-app);
  /* Fallback/darker bg */
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 32px;
  align-items: start;
}

.footer-col h4 {
  color: var(--text-secondary);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.footer-logos {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.footer-logos img {
  height: 26px;
  opacity: 0.85;
  filter: grayscale(100%);
  transition: 0.2s ease;
}

.footer-logos img:hover {
  opacity: 1;
  filter: none;
}

.footer-center {
  text-align: center;
}

.footer-right {
  text-align: right;
}

.footer-highlight {
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
}

.footer-socials {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
}

.footer-socials img {
  width: 20px;
  height: 20px;
  opacity: 0.6;
  transition: 0.2s ease;
}

.footer-socials img:hover {
  opacity: 1;
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-right,
  .footer-center {
    text-align: center;
  }

  .footer-socials {
    justify-content: center;
  }
}

/* ==========================================================================
   Components
   Description: Reusable UI components (Buttons, Inputs, Cards, Modals).
   ========================================================================== */

/* Typography Utils */
h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Cards */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.4s ease-out;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(81, 192, 180, 0.1);
  background: rgba(0, 0, 0, 0.4);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  width: fit-content;
}

.tab {
  padding: 8px 24px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(97, 47, 201, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(97, 47, 201, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent) 0%, #3a968b 100%);
  color: #080319;
  box-shadow: 0 4px 15px rgba(81, 192, 180, 0.3);
}

.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

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

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Modals */
.metadata-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 3, 25, 0.85);
  backdrop-filter: blur(6px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.metadata-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 700px;
  max-width: 95vw;
  max-height: 85vh;
  padding: 24px;
  overflow: hidden;
  position: relative;
}

.metadata-modal-content pre {
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
}

.modal,
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 3, 25, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content,
.image-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 80vw;
  max-height: 80vh;
  width: auto;
  padding: 24px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.image-modal-content img {
  max-width: 100%;
  max-height: 65vh;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.image-modal-controls {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: 0.2s ease;
}

.close:hover {
  color: var(--text-main);
}

pre {
  background: #000;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--accent);
  overflow-x: auto;
  font-size: 0.85rem;
}

/* ==========================================================================
   Modules
   Description: Specific application features (Camera, Gallery, Queue, etc.).
   ========================================================================== */

/* Value Props */
.value-props {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.prop {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.2s ease, border-color 0.2s;
}

.prop:hover {
  border-color: var(--primary);
  background: rgba(97, 47, 201, 0.05);
}

.prop-icon {
  font-size: 1.25rem;
}

.prop-text {
  display: flex;
  flex-direction: column;
}

.prop-text strong {
  font-size: 0.9rem;
  color: var(--text-main);
}

.prop-text small {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Dataset Size Selector */
.size-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.size-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.size-btn:hover {
  border-color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.02);
}

.size-btn.active {
  border-color: var(--primary);
  background: rgba(97, 47, 201, 0.1);
  box-shadow: 0 0 0 1px var(--primary);
}

.size-label {
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
}

.size-number {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

.size-btn small {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* Camera Cockpit & Parameters */
.parameters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media(min-width: 768px) {
  .parameters-grid {
    grid-template-columns: 1.5fr 1fr;
  }
}

.camera-control-panel {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.camera-slider-group {
  margin-bottom: 24px;
}

.camera-slider-group label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.slider-value {
  color: var(--accent);
  font-family: monospace;
}

.slider-markers {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  font-family: monospace;
}

/* Range Input Customization */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--surface-hover);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(97, 47, 201, 0.2);
  transition: background 0.15s, transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  background: #7c4dff;
}

/* 3D Preview Cube */
.camera-preview-3d {
  margin-top: 24px;
  padding: 20px;
  background: #000;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.preview-container {
  height: 180px;
  position: relative;
  perspective: 800px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(rgba(81, 192, 180, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(81, 192, 180, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

.object-cube {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary), #321a6b);
  border: 1px solid var(--accent);
  box-shadow: 0 0 20px rgba(97, 47, 201, 0.5);
  transform-style: preserve-3d;
  border-radius: 4px;
}

.camera-indicator {
  position: absolute;
  font-size: 24px;
  filter: drop-shadow(0 0 5px var(--accent));
}

/* Lighting Controls */
.lighting-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.lighting-presets label {
  margin: 0;
}

.lighting-presets input[type="checkbox"] {
  display: none;
}

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  height: 100%;
}

.preset-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
}

input[type="checkbox"]:checked+.preset-card {
  background: rgba(81, 192, 180, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(81, 192, 180, 0.15) inset;
}

.preset-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

/* Advanced Params Accordion */
.advanced-params-section {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.accordion-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.accordion-toggle:hover {
  color: var(--text-main);
  border-color: var(--text-tertiary);
}

.accordion-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 20px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 24px;
  background: var(--surface-hover);
  border-radius: 4px;
  overflow: hidden;
  margin: 24px 0 12px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--primary);
}

/* Results Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.gallery-item {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  border-color: var(--primary);
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #000;
}

.gallery-item-info {
  padding: 16px;
}

.gallery-item-info h4 {
  color: var(--text-main);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.gallery-item-info p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

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

/* Proof Grid (Disentanglement) */
.proof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.proof-item {
  background: var(--surface-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.3s;
  position: relative;
}

.proof-item:hover {
  border-color: var(--accent);
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(81, 192, 180, 0.2);
}

.proof-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #000;
}

.proof-label {
  padding: 12px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}

.proof-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Manual Queue Items */
.queue-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.queue-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
}

.queue-item-params {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-main);
}

.queue-item-remove {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
}

.queue-item-remove:hover {
  background: rgba(239, 68, 68, 0.3);
  transform: scale(1.05);
}

.queue-item-badge {
  background: var(--accent);
  color: var(--bg-app);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 8px;
}

/* API Key Modal Animations */
#api-key-modal .modal-content {
  animation: slideInDown 0.3s ease-out;
  transform: translateY(-30px);
}

#user-api-key {
  font-size: 0.9rem;
}

#user-api-key::placeholder {
  color: var(--text-tertiary);
  opacity: 0.5;
}

/* Image Preview in Forms */
.image-preview-container img {
  max-width: 200px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
}

/* ==========================================================================
   Utilities
   Description: Animations and helper classes.
   ========================================================================== */

.loading {
  color: var(--accent);
  font-weight: 500;
}

.error {
  color: #ff4d4d;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}