﻿/* Bakery Calculator - Stylesheet (v2.1.0-b4k3r4) */
:root {
  color-scheme: light dark;
  --bg-main: light-dark(#FDF8F3, #1A120E);
  --surface: light-dark(#FFFFFF, #261B16);
  --surface-elevated: light-dark(#FFFDF9, #32231D);
  --surface-input: light-dark(#F9F2EB, #1F1511);
  --text-primary: light-dark(#4A2818, #F7ECE4);
  --text-muted: light-dark(#8C7063, #B89C8E);
  --primary: light-dark(#E0636C, #E5737B);
  --primary-dark: light-dark(#C44D56, #C75B63);
  --primary-light: light-dark(#FBE8EA, #442226);
  --border: light-dark(#F2DFCE, #443026);
  --border-focus: light-dark(#E0636C, #E5737B);
  --gold: light-dark(#C89B5E, #E0B47A);
  --success: light-dark(#2E8B57, #45B277);
  --success-light: light-dark(#E6F4EA, #1A3826);
  --danger: light-dark(#C93B2B, #E25B4C);
  --danger-light: light-dark(#FCE8E6, #3E1D19);
  --warning: light-dark(#D97706, #F59E0B);
  --warning-light: light-dark(#FEF3C7, #422806);

  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.14);

  --nav-height: 64px;
  --header-height: 60px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 16px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 16px) + 12px);
  padding-top: env(safe-area-inset-top, 0px);
}

/* Accessibility: focus ring */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Container */
.app-container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.brand-text h1 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

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

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-elevated);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  transition: color 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.nav-item .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item:active {
  transform: scale(0.92);
}

/* Views router */
.view-section {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
  padding-top: 14px;
}

.view-section.active {
  display: block;
}

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

/* Card components */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Postre selector in hero */
.recipe-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.select-styled {
  flex: 1;
  appearance: none;
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238C7063' 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;
  padding-right: 36px;
}

/* Hero Radial KPI */
.hero-radial-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  position: relative;
}

.radial-kpi-wrap {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radial-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.radial-bg-circle {
  fill: none;
  stroke: var(--surface-input);
  stroke-width: 10;
}

.radial-stroke-cost {
  fill: none;
  stroke: var(--warning);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.radial-stroke-profit {
  fill: none;
  stroke: var(--success);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.radial-center-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.radial-center-text .margin-value {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.radial-center-text .margin-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.hero-submetrics {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.submetric-item {
  text-align: center;
}

.submetric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.submetric-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ROI & Break-even Card */
.roi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.roi-metric {
  background: var(--surface-input);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.roi-metric .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.roi-metric .value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

.progress-track {
  width: 100%;
  height: 10px;
  background-color: var(--surface-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  margin: 10px 0 6px 0;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--warning), var(--success));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.narrative-box {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin-top: 6px;
}

.narrative-highlight {
  font-weight: 700;
  color: var(--primary-dark);
}

/* Interactive Simulator */
.sim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sim-slider {
  width: 100%;
  margin: 10px 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.sim-display-bubble {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.9rem;
}

/* Big Action Button (Hornear) */
.btn-bake-cta {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(224, 99, 108, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-bake-cta:hover {
  box-shadow: 0 6px 18px rgba(224, 99, 108, 0.45);
}

.btn-bake-cta:active {
  transform: scale(0.97);
}

/* Fast Input Bar for Stock */
.fast-capture-box {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.fast-capture-box h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.fast-input-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 0.8fr auto;
  gap: 6px;
  align-items: center;
}

@media (max-width: 440px) {
  .fast-input-grid {
    grid-template-columns: 1fr 1fr;
  }
  .fast-input-grid .btn-submit-fast {
    grid-column: span 2;
  }
}

.input-ctrl {
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.input-ctrl:focus {
  border-color: var(--border-focus);
}

.btn-primary {
  background-color: var(--primary);
  color: #FFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.btn-primary:active {
  transform: scale(0.96);
}

.btn-secondary {
  background-color: var(--surface-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

/* List Items (Stock & Recetas) */
.item-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.item-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-warning {
  background-color: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background-color: var(--danger-light);
  color: var(--danger);
}

.badge-success {
  background-color: var(--success-light);
  color: var(--success);
}

.badge-info {
  background-color: var(--primary-light);
  color: var(--primary);
}

.item-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 2px;
}

.btn-one-touch {
  background-color: var(--surface-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-one-touch:hover {
  background-color: var(--border);
}

/* Recipes Wizard / Chips */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.chip-btn {
  background-color: var(--surface-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip-btn:active {
  transform: scale(0.95);
}

/* Foldable Accordion */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 10px;
  overflow: hidden;
}

.accordion-header {
  background-color: var(--surface-input);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accordion-body {
  padding: 14px;
  background-color: var(--surface);
  display: none;
}

.accordion.open .accordion-body {
  display: block;
}

/* Form Groups */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.25s ease forwards;
  pointer-events: auto;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Native Dialog / Modal */
dialog.custom-modal {
  margin: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-primary);
  padding: 20px;
  max-width: 460px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

dialog.custom-modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

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

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Driver.js theme custom styling */
.driver-popover {
  background-color: var(--surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-family) !important;
}

.driver-popover-title {
  color: var(--primary-dark) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

.driver-popover-description {
  color: var(--text-primary) !important;
  font-size: 0.85rem !important;
  line-height: 1.4 !important;
}

/* Close button - completely eliminate focus box / outline / borders */
.driver-popover-close-btn {
  all: unset !important;
  position: absolute !important;
  top: 6px !important;
  right: 6px !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-size: 1.1rem !important;
  line-height: 1 !important;
  color: var(--text-muted) !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  border-radius: var(--radius-sm) !important;
  transition: color 0.15s ease, background-color 0.15s ease !important;
}

.driver-popover-close-btn:hover,
.driver-popover-close-btn:focus,
.driver-popover-close-btn:focus-visible,
.driver-popover-close-btn:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--primary) !important;
  background-color: var(--surface-input) !important;
}

/* Footer buttons - eliminate text-shadow (fixing double/ghost text bug) */
.driver-popover-footer button {
  all: unset !important;
  display: inline-block !important;
  box-sizing: border-box !important;
  background-color: var(--surface-input) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 6px 12px !important;
  font-size: 0.78rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  text-shadow: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease !important;
}

.driver-popover-footer button:hover {
  background-color: var(--border) !important;
  text-shadow: none !important;
}

.driver-popover-footer button.driver-popover-next-btn {
  background-color: var(--primary) !important;
  color: #FFFFFF !important;
  border-color: var(--primary) !important;
  font-weight: 600 !important;
  text-shadow: none !important;
}

.driver-popover-footer button.driver-popover-next-btn:hover {
  background-color: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  text-shadow: none !important;
}

.driver-popover-progress-text {
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
}

/* Popover Arrow matches dynamic surface */
.driver-popover-arrow-side-left { border-left-color: var(--surface) !important; }
.driver-popover-arrow-side-right { border-right-color: var(--surface) !important; }
.driver-popover-arrow-side-top { border-top-color: var(--surface) !important; }
.driver-popover-arrow-side-bottom { border-bottom-color: var(--surface) !important; }



