﻿/* ==========================================================================
   TVH PaletteGen Pro - Master Application Stylesheet
   Design System: TVH Dark Glassmorphism + Outfit/Inter Typography
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-space);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(at 15% 15%, rgba(56, 189, 248, 0.08) 0px, transparent 45%),
    radial-gradient(at 85% 85%, rgba(129, 140, 248, 0.06) 0px, transparent 45%),
    radial-gradient(at 50% 50%, rgba(192, 132, 252, 0.03) 0px, transparent 60%);
  background-attachment: fixed;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-elevated);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* App Header */
.app-header {
  height: 64px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
}

.brand-badge {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #030712;
  font-weight: 900;
  font-size: 0.82rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-pure);
  letter-spacing: -0.02em;
}

.brand-title span {
  color: var(--primary);
}

.brand-version {
  font-size: 0.72rem;
  font-family: var(--font-code);
  color: var(--text-dim);
  background: var(--glass-bg-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
}

/* Nav Tabs */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(8, 12, 22, 0.6);
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.nav-tab {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  user-select: none;
}

.nav-tab:hover {
  color: var(--text-pure);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: var(--primary);
  background: var(--glass-bg-active);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #0284c7);
  color: #030712;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 20px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(129, 140, 248, 0.3);
}

.btn-accent:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.4);
  transform: translateY(-1px);
}

.btn-subtle {
  background: var(--glass-bg-subtle);
  color: var(--text-main);
  border-color: var(--glass-border);
}

.btn-subtle:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--glass-border-hover);
  color: var(--text-pure);
}

.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
}

/* Master Palette Live Strip (Always Visible Hero Section) */
.palette-hero {
  background: var(--bg-dark);
  border-bottom: 1px solid var(--glass-border);
  padding: 1.25rem 1.5rem;
}

.palette-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.palette-meta-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.palette-name-input {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-pure);
  background: transparent;
  border: 1px dashed transparent;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  outline: none;
  transition: var(--transition-fast);
}

.palette-name-input:hover,
.palette-name-input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
}

.palette-controls-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.palette-strip-container {
  display: flex;
  height: 140px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--glass-border);
}

.color-swatch-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
  position: relative;
  transition: flex 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.color-swatch-column:hover {
  flex: 1.35;
}

.swatch-top-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.color-swatch-column:hover .swatch-top-actions {
  opacity: 1;
}

.swatch-btn {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.swatch-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.1);
}

.swatch-btn.locked {
  background: var(--warning);
  color: #000;
  border-color: transparent;
}

.swatch-bottom-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.swatch-hex-val {
  font-family: var(--font-code);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.swatch-color-name {
  font-size: 0.72rem;
  opacity: 0.85;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch-picker-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* App Main Layout */
.app-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.view-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.view-pane.active {
  display: block;
}

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

/* Common Section & Card Styles */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--glass-border);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-pure);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title i {
  color: var(--primary);
}

/* Image Extractor View Styles */
.dropzone-container {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--glass-bg-subtle);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.dropzone-container:hover,
.dropzone-container.dragover {
  border-color: var(--primary);
  background: var(--glass-bg-active);
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.15);
}

.sample-images-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.sample-img-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--glass-border);
  cursor: pointer;
  transition: var(--transition-fast);
}

.sample-img-thumb:hover,
.sample-img-thumb.active {
  border-color: var(--primary);
  transform: scale(1.08);
}

.image-canvas-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--glass-border);
  cursor: crosshair;
}

#extractorCanvas {
  display: block;
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Eyedropper Magnifier Loupe */
.eyedropper-loupe {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 15px var(--primary-glow);
  pointer-events: none;
  display: none;
  overflow: hidden;
  z-index: 50;
  background: #000;
}

.loupe-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.loupe-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  box-shadow: 0 0 2px #000;
  pointer-events: none;
}

.loupe-color-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-code);
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 1px 6px;
  border-radius: 99px;
  white-space: nowrap;
}

/* Distribution Bar */
.distribution-bar {
  display: flex;
  height: 28px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 1rem 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--glass-border);
}

.dist-slice {
  height: 100%;
  transition: width 0.3s ease;
  position: relative;
  cursor: pointer;
}

.dist-slice:hover {
  filter: brightness(1.2);
}

/* Vibrant Breakdown Grid */
.vibrant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.vibrant-card {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.vibrant-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.vibrant-color-block {
  height: 48px;
  border-radius: var(--radius-xs);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.vibrant-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vibrant-hex {
  font-family: var(--font-code);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Harmonizer View Styles */
.harmony-picker-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.harmony-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.harmony-btn {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.harmony-btn:hover {
  border-color: var(--primary);
  background: var(--bg-surface-elevated);
}

.harmony-btn.active {
  background: var(--glass-bg-active);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.harmony-btn-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}

.harmony-btn-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Shades & Tints 50-950 Grid */
.shades-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 0.4rem;
  margin-top: 1rem;
}

.shade-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.shade-block {
  width: 100%;
  height: 54px;
  border-radius: var(--radius-xs);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
  transition: transform 0.15s ease;
}

.shade-item:hover .shade-block {
  transform: scale(1.08);
}

.shade-step {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.shade-hex {
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--text-dim);
}

/* Presets Grid */
.presets-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.category-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip {
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.chip:hover,
.chip.active {
  background: var(--glass-bg-active);
  color: var(--primary);
  border-color: var(--primary);
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.preset-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.preset-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.preset-colors-row {
  display: flex;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.preset-color-slice {
  flex: 1;
  height: 100%;
}

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

.preset-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-pure);
}

.preset-category-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--bg-surface-elevated);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

/* WCAG Matrix View */
.contrast-matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.contrast-matrix-table th,
.contrast-matrix-table td {
  padding: 0.75rem;
  text-align: center;
  border: 1px solid var(--glass-border);
}

.contrast-matrix-table th {
  background: var(--bg-surface);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.badge-aaa {
  background: rgba(16, 185, 129, 0.2);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 800;
}

.badge-aa {
  background: rgba(56, 189, 248, 0.2);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 800;
}

.badge-aalarge {
  background: rgba(245, 158, 11, 0.2);
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 800;
}

.badge-fail {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 800;
}

/* UI Mockup View */
.mockup-frame {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
}

.mockup-navbar {
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mockup-body {
  padding: 1.75rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.25rem;
}

.mockup-card {
  padding: 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.mockup-badge {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 800;
}

.mockup-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
}

.mockup-btn {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.code-export-box {
  background: #030712;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-code);
  font-size: 0.82rem;
  color: #38BDF8;
  white-space: pre;
  overflow-x: auto;
  max-height: 280px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 15px var(--primary-glow);
  color: var(--text-pure);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toastIn 0.25s ease-out forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive */
@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
  .header-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }
  .harmony-picker-row {
    grid-template-columns: 1fr;
  }
  .mockup-body {
    grid-template-columns: 1fr;
  }
  .shades-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}
