/**
 * Estilos visuales de la Calculadora de costes ocultos y mermas de coctelería
 * Fijate Tools - Bar Cost & Pour Cost Calculator
 */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta base oscura (coctelería nocturna) */
  --bg-page: #0a0d14;
  --bg-card: #121824;
  --bg-card-subtle: #182234;
  --bg-card-hover: #1f2b40;
  --bg-card-header: #182234;
  --bg-input: #121824;
  --bg-surface: #121824;
  --border-color: #243048;
  --border-color-focus: #f59e0b;

  --text-main: #f3f4f6;
  --text-primary: #f3f4f6;
  --text-muted: #9ca3af;
  --text-secondary: #9ca3af;
  --text-dim: #6b7280;

  --container-max: 1440px;

  /* Acentos de coctelería y variables canónicas de cabecera/botones */
  --primary-color: #f59e0b;
  --primary-light: rgba(245, 158, 11, 0.15);
  --accent-amber: #f59e0b;
  --accent-amber-hover: #d97706;
  --accent-amber-light: rgba(245, 158, 11, 0.12);

  --accent-teal: #14b8a6;
  --accent-teal-light: rgba(20, 184, 166, 0.12);

  --status-good: #10b981;
  --status-good-bg: rgba(16, 185, 129, 0.12);
  --status-warn: #f59e0b;
  --status-warn-bg: rgba(245, 158, 11, 0.12);
  --status-danger: #ef4444;
  --status-danger-bg: rgba(239, 68, 68, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --bg-card-header: #f1f5f9;
  --bg-input: #ffffff;
  --bg-surface: #ffffff;
  --border-color: #cbd5e1;
  --border-color-focus: #d97706;

  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-muted: #475569;
  --text-secondary: #475569;
  --text-dim: #64748b;

  --container-max: 1440px;

  --primary-color: #d97706;
  --primary-light: rgba(217, 119, 6, 0.12);
  --accent-amber: #d97706;
  --accent-amber-hover: #b45309;
  --accent-amber-light: rgba(217, 119, 6, 0.1);

  --accent-teal: #0d9488;
  --accent-teal-light: rgba(13, 148, 136, 0.1);

  --status-good: #059669;
  --status-good-bg: rgba(5, 150, 105, 0.1);
  --status-warn: #d97706;
  --status-warn-bg: rgba(217, 119, 6, 0.1);
  --status-danger: #dc2626;
  --status-danger-bg: rgba(220, 38, 38, 0.1);

  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.06);
}

/* Base de layout */
body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0;
}

.text-mono {
  font-family: var(--font-mono);
}

.text-muted {
  color: var(--text-muted);
}

.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.tool-main-content {
  min-width: 0;
  width: 100%;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

.tool-ad-sidebar {
  display: none;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
    position: sticky;
    top: 1rem;
  }
}

/* Tarjetas y contenedores */
.bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  box-sizing: border-box;
}

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

.bar-card-title {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

/* Selector de recetas rápidas */
.recipe-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.recipe-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.5rem;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.recipe-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-amber);
  transform: translateY(-1px);
}

.recipe-btn.active {
  background: var(--accent-amber-light);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
  font-weight: 600;
}

/* KPIs principales */
.kpi-dashboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .kpi-dashboard {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-tile {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-sizing: border-box;
}

.kpi-tile-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.kpi-tile-value {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main);
}

.kpi-tile-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Semáforo de Pour Cost */
.pour-cost-meter-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.meter-bar-track {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  display: flex;
}

.meter-target-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ffffff;
  z-index: 5;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

.meter-target-badge {
  position: absolute;
  top: -24px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  background: #ffffff;
  color: #000000;
  padding: 2px 5px;
  border-radius: 4px;
  transform: translateX(-50%);
  font-weight: 700;
  white-space: nowrap;
}

.meter-fill {
  height: 100%;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.meter-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  font-family: var(--font-mono);
}

/* Estados del semáforo */
.status-exceptional {
  color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
}

.status-optimal {
  color: var(--status-good);
  background-color: var(--status-good-bg);
  border-color: rgba(16, 185, 129, 0.3);
}

.status-warning {
  color: var(--status-warn);
  background-color: var(--status-warn-bg);
  border-color: rgba(245, 158, 11, 0.3);
}

.status-danger {
  color: var(--status-danger);
  background-color: var(--status-danger-bg);
  border-color: rgba(239, 68, 68, 0.3);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid currentColor;
}

/* Formulario y tabla de ingredientes */
.ingredients-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.ingredients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ingredients-table th {
  text-align: left;
  padding: 0.65rem 0.5rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

.ingredients-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

[data-theme="light"] .ingredients-table td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Campos de formulario responsivos */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control,
input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0.4rem 0.75rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

select {
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

select option {
  background: var(--bg-card);
  color: var(--text-main);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--border-color-focus);
}

.input-suffix-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 42px;
}

.input-suffix-wrapper:focus-within {
  border-color: var(--border-color-focus);
}

.input-suffix-wrapper input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  height: 100%;
  padding: 0 0.75rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.input-suffix-wrapper .suffix {
  padding: 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.03);
  height: 100%;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
  user-select: none;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 42px;
  min-height: 42px;
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--accent-amber);
  color: #0b0f17;
}

.btn-primary:hover {
  background: var(--accent-amber-hover);
  color: #ffffff;
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-amber);
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--status-danger);
  padding: 0 0.5rem;
  height: 34px;
  min-height: 34px;
}

.btn-danger-outline:hover {
  background: var(--status-danger-bg);
  border-color: var(--status-danger);
}

.btn-full {
  width: 100%;
}

/* Sliders de calibración de mermas */
.range-group {
  margin-bottom: 1.15rem;
}

.range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  margin-bottom: 0.35rem;
}

.range-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-amber);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
  appearance: none;
  margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-amber);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Modos de servicio (Jigger vs Free Pour) */
.toggle-pills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.toggle-pill {
  height: 44px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.toggle-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.toggle-pill.active {
  background: var(--accent-amber-light);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* Caja del simulador de pérdidas Free Pour */
.free-pour-simulator-box {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(245, 158, 11, 0.06) 100%);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.free-pour-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.free-pour-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.free-pour-lost-eur {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--status-danger);
}

/* Ficha técnica imprimible */
.sheet-preview-box {
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.sheet-header-print {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

/* Modales accesibles */
.custom-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.custom-modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}

.custom-modal-title {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.custom-modal-content {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.custom-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Responsive móvil */
@media (max-width: 640px) {
  .tool-layout {
    padding: 0 0.75rem;
  }
  .bar-card {
    padding: 1rem;
  }
  .kpi-dashboard {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }
  .kpi-tile-value {
    font-size: 1.35rem;
  }
}

/* Reglas de impresión A4 */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .no-print,
  .recipe-selector-grid,
  .btn,
  .custom-modal-backdrop,
  .tools-affiliate-section,
  .related-tools-section {
    display: none !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .tool-with-sidebar {
    display: block !important;
  }

  .bar-card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    page-break-inside: avoid;
    margin-bottom: 1cm;
  }

  .sheet-preview-box {
    border: 1px solid #000000 !important;
    padding: 1cm !important;
  }

  .ingredients-table th,
  .ingredients-table td {
    color: #000000 !important;
    border-color: #dddddd !important;
  }
}
