/* Capy-Cool Customizer Studio Styles */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap');

:root {
  --font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg-primary: #12151c;
  --bg-surface: #1a1e29;
  --bg-card: #222838;
  --bg-hover: #2d354b;
  --border-color: #2f374e;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ff6b4a;
  --accent-hover: #ff8266;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.app-header {
  background: rgba(26, 30, 41, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
  background: linear-gradient(135deg, #e27e36, #ff6b4a);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(226, 126, 54, 0.35);
}

.brand-info h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.brand-info p a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

.brand-info p a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* View Mode Pills */
.view-selector {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 3px;
  gap: 2px;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 107, 74, 0.4);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: #434d6b;
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b4a, #e25b39);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(255, 107, 74, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff7e60, #ee6442);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
}

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

/* Layout */
.main-container {
  display: grid;
  grid-template-columns: 1fr 440px;
  flex: 1;
  height: calc(100vh - 70px);
  overflow: hidden;
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .stage-section {
    overflow: visible !important;
    height: auto !important;
    padding: 20px 16px 36px 16px !important;
    position: relative !important;
    z-index: 100 !important;
  }

  .customizer-sidebar {
    overflow: visible !important;
    height: auto !important;
    border-left: none !important;
    border-top: 1px solid var(--border-color) !important;
    position: relative !important;
    z-index: 10 !important;
  }

  .tab-content-area {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    padding: 16px 14px 60px 14px !important;
  }
}

/* Stage / Canvas Section */
.stage-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 24px 80px 24px;
  position: relative;
  background: radial-gradient(circle at center, #1e2433 0%, #12151c 100%);
  overflow-y: auto;
}

.latam-flag-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.84rem;
  font-weight: 500;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.latam-flag-select:hover {
  border-color: #475569;
}

.latam-flag-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-match-flag {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.btn-match-flag:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-main);
  transform: translateY(-1px);
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 3 / 4;
  background: linear-gradient(to bottom, #ffffff 0%, #ffffff 73.242%, #191923 73.242%, #191923 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background 0.3s ease;
}

/* LATAM Flag Background Layer - White top region (y=0 to 750 / 1024 = 73.242%) */
.latam-bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 73.242%;
  pointer-events: none;
  z-index: 1;
  display: none;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.latam-bg-layer.active {
  display: block;
}

.latam-bg-layer svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#characterCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.stage-actions {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 430px;
}

.stage-actions .btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(255, 107, 74, 0.35);
  cursor: pointer;
}

/* Sidebar Section */
.customizer-sidebar {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: rgba(26, 30, 41, 0.5);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(255, 107, 74, 0.05);
}

/* Tab Content */
.tab-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease;
}

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

/* Quick Actions in Clothes Tab */
.clothes-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.clothes-quick-actions .btn {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  transition: all 0.2s ease;
  cursor: pointer;
}

.clothes-quick-actions .btn:hover {
  background: var(--bg-hover);
  border-color: #475569;
  transform: translateY(-1px);
}

.clothes-quick-actions .btn:active {
  transform: translateY(0);
}

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

/* Category Sections */
.category-group {
  margin-bottom: 24px;
}

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

.category-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Color Palette Swatches */
.palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.swatch-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.swatch-btn:hover {
  transform: scale(1.15);
}

.swatch-btn.active {
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.picker-input {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: none;
}

/* Presets List */
.presets-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preset-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-card:hover {
  background: var(--bg-hover);
  border-color: #475569;
}

.preset-info h4 {
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.preset-info p {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid #334155;
  border-left: 4px solid var(--accent);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.84rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* SVG Vector Stage */
.svg-stage-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.svg-stage-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Vector Section Garment Cards */
.vector-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}

.vector-section-card:hover {
  border-color: #475569;
}

.vector-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.vector-row label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==================== FLOATING PREVIEW (MOBILE) ==================== */
.floating-preview {
  position: fixed;
  top: calc(74px + env(safe-area-inset-top, 0px));
  right: 14px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-14px) scale(0.88);
  transition: opacity 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  outline: none;
}

@media (min-width: 1025px) {
  .floating-preview {
    display: none !important;
  }
}

.floating-preview.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.floating-preview-card {
  width: 82px;
  background: var(--bg-surface);
  border: 2px solid rgba(255, 107, 74, 0.7);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 24px -2px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.floating-preview:active .floating-preview-card,
.floating-preview:focus-visible .floating-preview-card {
  transform: scale(0.94);
  border-color: var(--accent);
}

.floating-preview-card.preview-pulse {
  animation: floatingPreviewPulse 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes floatingPreviewPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 74, 0.9), 0 10px 24px -2px rgba(0, 0, 0, 0.75);
    border-color: #ff8f75;
  }
  50% {
    box-shadow: 0 0 18px 4px rgba(255, 107, 74, 0.6), 0 10px 24px -2px rgba(0, 0, 0, 0.75);
    border-color: #ff6b4a;
  }
  100% {
    box-shadow: 0 10px 24px -2px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 107, 74, 0.7);
  }
}

.floating-preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(to bottom, #ffffff 0%, #ffffff 73.242%, #191923 73.242%, #191923 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.floating-svg-stage {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-svg-stage svg {
  width: 100%;
  height: 100%;
  display: block;
}

.floating-preview-footer {
  background: rgba(18, 21, 28, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 6px;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.floating-preview-arrow {
  font-size: 0.58rem;
  display: inline-block;
  animation: floatingArrowBounce 1.5s infinite ease-in-out;
}

@keyframes floatingArrowBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

