/**
 * ============================================================================
 * ToolsTurbo Design System & Shared Component Toolkit (v1.0.0)
 * https://toolsturbo.com
 *
 * Centralized, authoritative styles for all ToolsTurbo tools.
 * DO NOT redefine these classes in individual tool style.css files.
 * ============================================================================
 */

/* ============================================================================
 * 1. DESIGN TOKENS & CSS CUSTOM PROPERTIES
 * ============================================================================ */
:root {
  /* Brand Gradients & Accents */
  --tt-brand-blue: #2563eb;
  --tt-brand-indigo: #5045e5;
  --tt-brand-purple: #7c3aed;
  --tt-brand-gradient: linear-gradient(90deg, #2563eb 0%, #5045e5 50%, #7c3aed 100%);
  --tt-brand-soft: #eff6ff;

  /* ToolsTurbo Standard Interface Colors */
  --tt-header-bg: #eef0f1;
  --tt-line-color: #dbdce0;
  --tt-line-size: 2pt;
  --tt-border: #dbdce0;
  --tt-border-hover: #93c5fd;
  --tt-border-focus: #2563eb;

  /* Typography & Neutral Palette */
  --tt-text: #161b33;
  --tt-text-muted: #64748b;
  --tt-text-subtle: #94a3b8;
  --tt-bg-page: #f8fafc;
  --tt-card-bg: #ffffff;
  --tt-input-bg: #ffffff;
  --tt-panel-bg: #ffffff;

  /* Semantic Alerts */
  --tt-danger: #dc2626;
  --tt-danger-soft: #fef2f2;
  --tt-success: #16a34a;
  --tt-success-soft: #f0fdf4;
  --tt-warning: #ea580c;
  --tt-warning-soft: #fff7ed;
  --tt-info: #0284c7;
  --tt-info-soft: #f0f9ff;

  /* Typography Fonts */
  --tt-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --tt-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

  /* Standard Border Radii */
  --tt-radius-xs: 4px;
  --tt-radius-sm: 6px;
  --tt-radius-md: 10px;
  --tt-radius-lg: 14px;
  --tt-radius-xl: 18px;
  --tt-radius-pill: 9999px;

  /* Elevation & Shadows */
  --tt-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --tt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --tt-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --tt-transition: all 0.15s ease;
}

/* ============================================================================
 * 2. DESKTOP 2-COLUMN WORKSPACE & RESPONSIVE LAYOUT
 * ============================================================================ */
.tt-generator-grid,
.tool-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  width: 100%;
  box-sizing: border-box;
}

/* Desktop layout (>= 800px): Left controls + Right sticky preview */
@media (min-width: 800px) {
  .tt-generator-grid,
  .tool-workspace-grid {
    grid-template-columns: minmax(0, 1fr) 390px;
    align-items: start;
  }
}

@media (min-width: 1200px) {
  .tt-generator-grid,
  .tool-workspace-grid {
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 28px;
  }
}

.tt-config-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.tt-preview-col {
  min-width: 0;
}

@media (min-width: 800px) {
  .tt-preview-col {
    position: sticky;
    top: 20px;
    z-index: 10;
  }
}

/* ============================================================================
 * 3. UNIFIED SPACE-SAVING CARD CONTAINER
 * ============================================================================ */
.tt-card {
  background: var(--tt-card-bg);
  border: var(--tt-line-size) solid var(--tt-border);
  border-radius: var(--tt-radius-xl);
  box-sizing: border-box;
}

.tt-unified-card {
  background: var(--tt-card-bg);
  border: var(--tt-line-size) solid var(--tt-border);
  border-radius: var(--tt-radius-xl);
  overflow: hidden;
  box-shadow: var(--tt-shadow-sm);
}

/* Card Header Strip: 100% standard background #eef0f1 */
.tt-card-header,
.tt-type-row {
  background: var(--tt-header-bg);
  padding: 14px 20px;
  border-bottom: var(--tt-line-size) solid var(--tt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tt-type-row-label,
.tt-card-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--tt-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tt-card-body {
  padding: 20px;
}

/* Panel Header Inside Tab Panels */
.tt-panel-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.tt-panel-icon {
  font-size: 1.25rem;
  line-height: 1;
  padding-top: 2px;
  color: var(--tt-brand-blue);
}

.tt-panel-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--tt-text);
  margin: 0 0 3px 0;
}

.tt-panel-subtitle {
  font-size: 0.82rem;
  color: var(--tt-text-muted);
  margin: 0;
}

/* ============================================================================
 * 4. SPACE-SAVING HORIZONTAL TABS BAR
 * ============================================================================ */
.tt-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: var(--tt-line-size) solid var(--tt-border);
  background: #ffffff;
  padding: 0 16px;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tt-tabs-bar::-webkit-scrollbar {
  display: none;
}

.tt-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: var(--tt-font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--tt-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--tt-transition);
  position: relative;
}

.tt-tab-btn:hover {
  color: var(--tt-text);
}

.tt-tab-btn.active {
  color: var(--tt-brand-blue);
  font-weight: 700;
  border-bottom: 3px solid transparent;
  border-image: var(--tt-brand-gradient);
  border-image-slice: 1;
}

.tt-tab-panels {
  background: #ffffff;
  padding: 18px 20px 22px;
}

.tt-tab-panel {
  display: none;
}

.tt-tab-panel.active {
  display: block;
}

/* Nested panel card resets inside unified card */
.tt-tab-panel .tt-panel-card {
  border: none;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

/* ============================================================================
 * 5. FORM INPUTS & INLINE ROWS
 * ============================================================================ */
.tt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.tt-field:last-child {
  margin-bottom: 0;
}

.tt-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--tt-text);
  margin: 0;
}

.tt-hint {
  font-size: 0.78rem;
  color: var(--tt-text-muted);
}

.tt-input,
.tt-select,
.tt-textarea {
  width: 100%;
  font-family: var(--tt-font-sans);
  font-size: 0.88rem;
  color: var(--tt-text);
  background: var(--tt-input-bg);
  border: var(--tt-line-size) solid var(--tt-border);
  border-radius: var(--tt-radius-md);
  padding: 10px 14px;
  box-sizing: border-box;
  outline: none;
  transition: var(--tt-transition);
}

.tt-input:focus,
.tt-select:focus,
.tt-textarea:focus {
  border-color: var(--tt-border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tt-textarea {
  resize: vertical;
  min-height: 85px;
}

/* Single Inline Input + Action Button Row */
.tt-inline-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.tt-input--inline {
  flex: 1;
  min-width: 0;
}

/* Grid Utilities */
.tt-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tt-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tt-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 580px) {
  .tt-grid-2,
  .tt-grid-3,
  .tt-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
 * 6. BUTTON SYSTEM
 * ============================================================================ */
.tt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--tt-font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--tt-radius-md);
  border: var(--tt-line-size) solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: var(--tt-transition);
  text-decoration: none;
}

.tt-btn:hover {
  transform: translateY(-1px);
}

.tt-btn:active {
  transform: translateY(0);
}

.tt-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Brand Primary Gradient */
.tt-btn--primary,
.tt-btn--generate {
  background: var(--tt-brand-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.tt-btn--primary:hover,
.tt-btn--generate:hover {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.38);
}

/* Secondary / Neutral */
.tt-btn--secondary {
  background: #ffffff;
  color: var(--tt-text);
  border-color: var(--tt-border);
}

.tt-btn--secondary:hover {
  background: #f8fafc;
  border-color: var(--tt-brand-blue);
  color: var(--tt-brand-blue);
}

/* Outline / Danger / Success */
.tt-btn--outline {
  background: transparent;
  color: var(--tt-brand-blue);
  border-color: var(--tt-brand-blue);
}

.tt-btn--danger {
  background: var(--tt-danger);
  color: #ffffff;
}

/* Sizes */
.tt-btn--sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--tt-radius-sm);
}

.tt-btn--lg {
  padding: 14px 24px;
  font-size: 0.98rem;
  border-radius: var(--tt-radius-lg);
}

.tt-btn--block {
  width: 100%;
}

/* Action button strip (Download, Copy, Share, Reset) */
.tt-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.tt-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tt-text);
  background: #ffffff;
  border: var(--tt-line-size) solid var(--tt-border);
  border-radius: var(--tt-radius-md);
  cursor: pointer;
  transition: var(--tt-transition);
}

.tt-action-btn:hover {
  background: #f8fafc;
  border-color: var(--tt-brand-blue);
  color: var(--tt-brand-blue);
}

/* ============================================================================
 * 7. STYLE CARDS & SELECTION CHIPS
 * ============================================================================ */
.tt-style-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.tt-style-card {
  border: var(--tt-line-size) solid var(--tt-border);
  background: #ffffff;
  border-radius: var(--tt-radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--tt-text);
  transition: var(--tt-transition);
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tt-style-card:hover {
  border-color: var(--tt-border-hover);
  background: #f8faff;
}

.tt-style-card.active {
  border-color: var(--tt-brand-blue) !important;
  background: #ffffff !important;
  color: var(--tt-brand-blue) !important;
  box-shadow: 0 0 0 1px var(--tt-brand-blue) !important;
}

.tt-style-card--sm {
  padding: 9px 8px;
  font-size: 0.82rem;
  min-height: 40px;
  border-radius: var(--tt-radius-sm);
  white-space: nowrap;
}

/* Palette Chips */
.tt-presets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tt-preset-chip,
.tt-eye-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--tt-radius-pill);
  border: var(--tt-line-size) solid var(--tt-border);
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tt-text);
  cursor: pointer;
  transition: var(--tt-transition);
}

.tt-preset-chip:hover,
.tt-eye-preset-chip:hover {
  border-color: var(--tt-brand-blue);
  background: #f8faff;
}

.tt-preset-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ============================================================================
 * 8. COLOR PICKERS & INLINE SELECTION BOXES
 * ============================================================================ */
.tt-color-picker-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: var(--tt-line-size) solid var(--tt-border);
  border-radius: var(--tt-radius-md);
  padding: 4px 8px;
  background: var(--tt-input-bg);
  box-sizing: border-box;
}

.tt-color-picker-box input[type="color"] {
  border: none;
  width: 30px;
  height: 30px;
  border-radius: var(--tt-radius-xs);
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.tt-color-picker-box input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.tt-color-picker-box input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius-xs);
}

.tt-color-hex {
  width: 76px;
  border: none;
  background: transparent;
  font-family: var(--tt-font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  text-transform: uppercase;
  outline: none;
  color: var(--tt-text);
}

.tt-color-picker-box--inline {
  flex: 0 0 120px;
  height: 40px;
  padding: 2px 8px;
  gap: 6px;
}

.tt-color-picker-box--inline input[type="color"] {
  width: 26px;
  height: 26px;
}

.tt-color-picker-box--inline .tt-color-hex {
  width: 66px;
  font-size: 0.82rem;
}

/* ============================================================================
 * 9. SLIDERS & RANGE CONTROLS
 * ============================================================================ */
.tt-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.tt-range,
.tt-slider {
  flex: 1;
  height: 6px;
  border-radius: var(--tt-radius-pill);
  background: var(--tt-border);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.tt-range::-webkit-slider-thumb,
.tt-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--tt-brand-blue);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
  cursor: grab;
  transition: transform 0.1s ease;
}

.tt-range::-webkit-slider-thumb:active,
.tt-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.18);
}

/* ============================================================================
 * 10. SWITCHES & TOGGLES
 * ============================================================================ */
.tt-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.tt-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.tt-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tt-slider-round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--tt-border);
  transition: 0.2s ease;
  border-radius: var(--tt-radius-pill);
}

.tt-slider-round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tt-switch input:checked + .tt-slider-round {
  background-color: var(--tt-brand-blue);
}

.tt-switch input:checked + .tt-slider-round:before {
  transform: translateX(20px);
}

/* ============================================================================
 * 11. FILE DROPZONE / UPLOAD AREA
 * ============================================================================ */
.tt-dropzone {
  border: 2px dashed var(--tt-border);
  border-radius: var(--tt-radius-lg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--tt-bg-page);
  transition: var(--tt-transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tt-dropzone:hover,
.tt-dropzone.dragover {
  border-color: var(--tt-brand-blue);
  background: #f8faff;
}

.tt-dropzone--compact {
  padding: 18px 16px;
  flex-direction: row;
  gap: 14px;
  text-align: left;
}

.tt-dropzone__icon {
  color: var(--tt-brand-blue);
  flex-shrink: 0;
}

.tt-dropzone__title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--tt-text);
}

.tt-dropzone__hint {
  font-size: 0.8rem;
  color: var(--tt-text-muted);
}

.tt-dropzone__browse {
  color: var(--tt-brand-blue);
  font-weight: 600;
  text-decoration: underline;
}

.tt-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================================================================
 * 12. RESULT / PREVIEW CARD (STICKY DESKTOP)
 * ============================================================================ */
.tt-preview-card {
  background: var(--tt-card-bg);
  border: var(--tt-line-size) solid var(--tt-border);
  border-radius: var(--tt-radius-xl);
  padding: 20px;
  box-shadow: var(--tt-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tt-preview-stage {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  border-radius: var(--tt-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Checkerboard transparent background preview */
.tt-preview-stage.checker-bg {
  background-image: linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
                    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
                    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* ============================================================================
 * 13. TOAST, ALERTS, AND DIVIDERS
 * ============================================================================ */
.tt-color-divider {
  height: 1px;
  background: var(--tt-border);
  margin: 16px 0;
}

.tt-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--tt-text);
  color: #ffffff;
  font-family: var(--tt-font-sans);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--tt-radius-md);
  box-shadow: var(--tt-shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.tt-toast.show {
  opacity: 1;
  transform: translateY(0);
}
