/* ===== VISUALIZADOR DE FUNÇÕES - ESTILOS ESPECÍFICOS ===== */

.viz-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

.viz-sidebar {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.viz-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
}

.plotly-chart {
  width: 100%;
  height: 520px;
  min-height: 400px;
}

.btn-full {
  width: 100%;
}

/* Form Row (side-by-side fields) */
.form-row {
  display: flex;
  gap: 12px;
}

.form-group-half {
  flex: 1;
  min-width: 0;
}

.form-group-half .form-input {
  width: 100%;
}

/* Range Slider */
.form-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  margin-top: 4px;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
  transition: transform 0.15s ease;
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

/* Checkbox Label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Parameter Group */
.param-group {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.param-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Custom function input color labels */
.form-label-color1 {
  border-left: 3px solid #6366f1;
  padding-left: 8px;
}

.form-label-color2 {
  border-left: 3px solid #10b981;
  padding-left: 8px;
}

.form-label-color3 {
  border-left: 3px solid #f43f5e;
  padding-left: 8px;
}

.fn-input {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
}

/* Checklist de Funções */
.fn-checklist {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fn-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.preset-btn {
  padding: 5px 12px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.preset-btn:hover {
  background: var(--primary);
  color: white;
}

.fn-select-all {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.select-all-btn,
.deselect-all-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.select-all-btn:hover,
.deselect-all-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.fn-check-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fn-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.fn-check-item:hover {
  background: rgba(102, 126, 234, 0.06);
  border-color: var(--border);
}

.fn-check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.fn-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.fn-check-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.fn-check-formula {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: 'Courier New', monospace;
}

/* Reference / Explanation Grid */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.ref-card {
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  transition: all var(--transition);
}

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

.ref-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ref-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.ref-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.ref-formula {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(102, 126, 234, 0.08);
  border-radius: 6px;
  display: inline-block;
}

.ref-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.ref-application {
  margin-top: 10px;
  font-size: 0.82rem;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 6px;
  color: #065f46;
  border-left: 3px solid var(--success);
}

[data-theme="dark"] .ref-application {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}

/* Error State */
.fn-error {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: #991b1b;
  font-size: 0.85rem;
  margin-top: -8px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.fn-error code {
  background: rgba(239, 68, 68, 0.12);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.82rem;
}

[data-theme="dark"] .fn-error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

[data-theme="dark"] .fn-error code {
  background: rgba(239, 68, 68, 0.2);
}

/* Tips List */
.tips-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tip-item {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
}

.tip-item code {
  background: rgba(102, 126, 234, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--primary-dark);
}

[data-theme="dark"] .tip-item code {
  background: rgba(102, 126, 234, 0.2);
  color: #a5b4fc;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 14px 20px 14px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  width: max-content;
  font-size: 0.95rem;
  font-weight: 500;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1a1a1a; }

.toast-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.75;
  flex-shrink: 0;
  font-family: inherit;
}

.toast-close:hover { opacity: 1; }

/* Hidden */
.hidden {
  display: none !important;
}

/* Responsive */
/* Focus visible para botões internos da checklist */
.preset-btn:focus-visible,
.select-all-btn:focus-visible,
.deselect-all-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

  .viz-sidebar {
    position: static;
  }

  .plotly-chart {
    height: 400px;
    min-height: 300px;
  }

  .ref-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* Touch target mínimo para sliders no mobile */
  .form-range {
    padding-top: 12px;
    padding-bottom: 12px;
  }
}

@media (max-width: 480px) {
  .plotly-chart {
    height: 320px;
    min-height: 250px;
  }

  .fn-presets {
    gap: 4px;
  }

  .preset-btn {
    font-size: 0.72rem;
    padding: 4px 8px;
  }
}