/* ==========================================================================
   Calculadora de Alcoholemia DGT - Estilos Principales
   Fijate Tools 2026
   ========================================================================== */

:root {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --color-primary: #38bdf8;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-crime: #dc2626;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Cabecera */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-back-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.btn-back-tools:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-box {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(245, 158, 11, 0.2));
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-danger);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: none !important;
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Layout Principal con Sidebar */
.main-wrapper {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.tool-main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* Hero */
.tool-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-full);
  color: var(--color-danger);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.tool-hero h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.tool-hero p {
  color: var(--text-muted);
  font-size: 0.975rem;
  max-width: 780px;
}

/* Tarjetas de cálculo */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

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

.card-header-flex .card-title {
  margin-bottom: 0;
}

/* Formularios */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control, .form-select {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
}

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-suffix {
  position: absolute;
  right: 1rem;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 600;
  pointer-events: none;
}

.radio-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.radio-card:hover {
  border-color: var(--color-primary);
}

.radio-card input[type="radio"] {
  accent-color: var(--color-primary);
}

/* Selector de Bebidas */
.drink-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.btn-drink {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
}

.btn-drink:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.drink-emoji {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.drink-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.drink-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Lista de consumiciones agregadas */
.consumed-list-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.empty-drinks-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1.5rem 1rem;
  text-align: center;
}

.drinks-table-wrapper {
  overflow-x: auto;
}

.drinks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.drinks-table th, .drinks-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.drinks-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-qty {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.btn-qty:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
}

.btn-del {
  background: transparent;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}

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

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

/* Semáforo de Estado */
.legal-status-banner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

.status-icon {
  font-size: 2.25rem;
  line-height: 1;
}

.status-info h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

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

.status-safe {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--color-success);
}
.status-safe .status-info h4 { color: var(--color-success); }

.status-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--color-warning);
}
.status-warning .status-info h4 { color: var(--color-warning); }

.status-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--color-danger);
}
.status-danger .status-info h4 { color: var(--color-danger); }

.status-crime {
  background: rgba(220, 38, 38, 0.25);
  border: 2px solid var(--color-crime);
  animation: pulse-crime 2s infinite;
}
.status-crime .status-info h4 { color: #f87171; }

@keyframes pulse-crime {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 20px 4px rgba(220, 38, 38, 0.6); }
}

/* Métricas Clave */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
}

.m-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.m-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.m-val.highlight {
  color: var(--color-primary);
}

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

/* Gráfica de Canvas */
.chart-container-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.chart-header h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot-curva {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38bdf8;
}

.dot-dgt {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

.canvas-wrapper {
  width: 100%;
  height: 260px;
  position: relative;
}

#canvas-curve {
  width: 100%;
  height: 100%;
  display: block;
}

/* Sanciones */
.penalties-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.penalties-box h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-danger);
  margin-bottom: 0.5rem;
}

.penalty-alert {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Información y Tablas */
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

.info-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  margin-bottom: 1.25rem;
}

.table-responsive {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.dgt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dgt-table th, .dgt-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.dgt-table th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 600;
}

.row-crime td {
  background: rgba(220, 38, 38, 0.1);
  color: #fca5a5;
  font-weight: 600;
}

.disclaimer-text {
  font-size: 0.825rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Modales */
.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: 100;
  padding: 1rem;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

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

.btn-primary {
  background: var(--color-primary);
  color: #0f172a;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

/* Responsivo */
@media (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .radio-toggle-group {
    grid-template-columns: 1fr;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .chart-legend {
    flex-direction: column;
    gap: 0.35rem;
  }
}
