/* ===========================
   BASE GENERAL
=========================== */

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f7f7f7;
  color: #111;
}

.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 32px;
}

h1, h2, h3, h4 {
  margin: 0 0 8px;
}

p {
  margin: 0 0 10px;
}

.muted {
  color: #666;
  font-size: 14px;
}

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ===========================
   NAVBAR
=========================== */

.topbar {
  background: #111;
  color: white;
}

.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.nav a {
  color: white;
  text-decoration: none;
}

.nav a:hover {
  text-decoration: underline;
}

.logout-form {
  margin-left: auto;
}

/* ===========================
   DASHBOARD / GRID / CARDS
=========================== */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-top: 20px;
}

.card {
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 16px;
}

.menu-card {
  display: block;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: #111;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: 0.15s ease;
}

.menu-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
  transform: translateY(-1px);
}

.menu-card:visited {
  color: #111;
}

.menu-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.menu-card p {
  margin: 0;
  color: #555;
  line-height: 1.35;
}

/* ===========================
   FORM GRID DASHBOARD
=========================== */

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-row label {
  width: 140px;
  font-size: 14px;
  font-weight: 500;
  color: #444;
}

.form-row input {
  flex: 1;
  padding: 6px 8px;
  font-size: 14px;
}

.form-actions {
  margin-top: 10px;
}



/* ===========================
   FLASH
=========================== */

.flash-stack {
  margin-bottom: 16px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.flash.success { background: #e8f6ea; }
.flash.error { background: #fdeaea; }

/* ===========================
   FORMULARIOS
=========================== */

input, select, button, textarea {
  width: 100%;
  padding: 10px;
  margin: 6px 0 12px;
  box-sizing: border-box;
  font: inherit;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.inline,
.snapshot-form,
.search-bar,
.actions,
.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.inline > * {
  flex: 1;
}

.button,
button {
  background: #111;
  color: white;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  padding: 10px 14px;
}

.button:hover,
button:hover {
  opacity: 0.95;
}

/* ===========================
   LOGIN
=========================== */

.login-wrapper {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  margin: 0 0 18px;
  text-align: center;
}

.login-card label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.login-card input,
.login-card button {
  width: 100%;
  box-sizing: border-box;
}

.login-card button {
  margin-top: 8px;
}

/* ===========================
   PRODUCT EDIT TABLE
=========================== */

.product-edit-table {
  width: 100%;
  table-layout: fixed;
}

.product-edit-table th,
.product-edit-table td {
  vertical-align: top;
}

.product-edit-table .col-name {
  width: 46%;
}

.product-edit-table .col-price {
  width: 10%;
}

.product-edit-table .col-category {
  width: 22%;
}

.product-edit-table .col-active {
  width: 8%;
  text-align: center;
}

.product-edit-table .col-actions {
  width: 14%;
}

.input-name {
  width: 100%;
  min-width: 260px;
}

.input-price {
  width: 88px;
  min-width: 88px;
  text-align: right;
}

.product-active-cell input[type="checkbox"] {
  width: auto;
  margin-top: 12px;
  transform: scale(1.1);
}

.allergen-row th,
.allergen-row td {
  border-bottom: 1px solid #eee;
}

.allergen-label-cell {
  font-weight: 600;
  color: #444;
  padding-top: 2px;
}

.allergen-value-cell {
  padding-top: 2px;
}

.allergen-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 12px;
}

.allergen-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 999px;
  background: #fafafa;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}

.allergen-chip input {
  display: none;
}

.allergen-chip:has(input:checked) {
  background: #111;
  color: white;
  border-color: #111;
}

.allergen-icon {
  font-size: 16px;
  line-height: 1;
}

.allergen-picker.compact {
  gap: 6px;
}

.allergen-chip.compact {
  padding: 4px 8px;
  font-size: 12px;
}

/* ===========================
   TABLAS
=========================== */

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}

/* ===========================
   FILTRO CATEGORÍAS
=========================== */

.category-filter-select {
  width: auto;
  min-width: 260px;
  margin: 0;
}

.category-panel {
  display: none;
  margin-top: 16px;
}

/* ===========================
   IMPRESIÓN BASE
=========================== */

.print-page {
  font-family: 'Cormorant Garamond', serif;
  max-width: 800px;
  margin: 20px auto;
  padding: 0 16px 16px;
  color: #111;
  background: white;
  position: relative;
  overflow: visible;
  display: block;
}

.watermark {
  position: fixed;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 55%;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.print-page > *:not(.watermark) {
  position: relative;
  z-index: 1;
}

.print-topbar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 20px;
}

.print-header.minimal {
  text-align: center;
  margin-bottom: 16px;
}

.menu-title {
  font-family: 'Playfair Display', serif;
  font-size: 34px;
  letter-spacing: 1px;
  font-weight: 600;
}

.print-category {
  margin-top: 12px;
  font-size: 19px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 3px;
  font-family: 'Playfair Display', serif;
}

.print-category.centered {
  border-bottom: 0;
  text-align: center;
}

.print-item-block {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 15px;
  line-height: 1.15;
}

.price {
  white-space: nowrap;
  text-align: right;
  min-width: 60px;
}

.allergens-text {
  font-size: 9px;
  color: #555;
  margin-top: 1px;
  line-height: 1.05;
}

.print-footer {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.allergen-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 12px;
}

.allergen-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 999px;
  background: #fafafa;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}

.allergen-chip input {
  display: none;
}

.allergen-chip:has(input:checked) {
  background: #111;
  color: white;
  border-color: #111;
}

.allergen-icon {
  font-size: 16px;
  line-height: 1;
}

.allergen-picker.compact {
  gap: 6px;
}

.allergen-chip.compact {
  padding: 4px 8px;
  font-size: 12px;
}


/* ===========================
   VINOS - NO CORTAR CATEGORÍAS
=========================== */

.wine-category-block {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 10px;
}

.wine-category-block .print-category {
  break-after: avoid;
  page-break-after: avoid;
}

.wine-category-block .print-item-block {
  padding: 1px 0;
  font-size: 14px;
  line-height: 1.05;
}

.wine-category-block .allergens-text {
  font-size: 8px;
  line-height: 1;
}

/* ===========================
   BEBIDAS - NO CORTAR CATEGORÍAS
=========================== */

.drink-category-block {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 10px;
}

.drink-category-block .print-category {
  break-after: avoid;
  page-break-after: avoid;
}

.drink-category-block .print-item-block {
  padding: 1px 0;
  font-size: 14px;
  line-height: 1.05;
}

.drink-category-block .allergens-text {
  font-size: 8px;
  line-height: 1;
}

/* ===========================
   SUGERENCIAS SIMPLE
=========================== */

.suggestions-single-page {
  flex: 1;
}

.suggestions-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.suggestions-content {
  width: 100%;
  max-width: 600px;
}

/* ===========================
   SUGERENCIAS x2
=========================== */

.suggestions-double-page {
  padding: 0;
}

.double-suggestions-sheet {
  height: calc(297mm - 12mm);
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}

.suggestion-half {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 4px 6px 2px;
  break-inside: avoid;
}

.half-watermark {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 55%;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.suggestion-half > *:not(.half-watermark) {
  position: relative;
  z-index: 1;
}

.suggestions-half-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.suggestions-half-inner {
  width: 100%;
  max-width: 520px;
}

.compact-suggestion-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  padding: 2px 0;
  line-height: 1.05;
  text-align: left;
}

.compact-suggestion-row .price {
  min-width: 55px;
  text-align: right;
}

.cut-line {
  border-top: 1px dashed #999;
  margin: 2px 0;
}

.print-toolbar {
  display: flex;
  gap: 10px;
  margin: 20px;
}

.print-toolbar button {
  padding: 8px 14px;
  border: 1px solid #111;
  background: white;
  cursor: pointer;
}

.print-toolbar button:hover {
  background: #111;
  color: white;
}

/* ===========================
   PRINT VIEW ON SCREEN
=========================== */

html, body {
  overflow-y: auto;
}

.print-page .print-container {
  overflow: visible;
}


/* ===========================
   PRINT ACTIONS BLOCKS
=========================== */

.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.print-actions-block h3 {
  margin-bottom: 12px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.actions-grid .button {
  text-align: center;
}

@media (max-width: 1100px) {
  .actions-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .actions-grid {
    grid-template-columns: 1fr;
  }
}

/* ===========================
   PRINT RULES
=========================== */

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html, body {
    margin: 0;
    padding: 0;
    overflow: visible;
    background: white;
  }

  .no-print,
  .topbar {
    display: none !important;
  }

  .print-page {
    margin: 0;
    max-width: 100%;
    padding: 6mm 10mm 6mm 10mm;
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .wine-category-block {
    break-inside: avoid-page;
    page-break-inside: avoid;
    orphans: 99;
    widows: 99;
  }

  .wine-category-block .print-category {
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .drink-category-block {
    break-inside: avoid-page;
    page-break-inside: avoid;
    orphans: 99;
    widows: 99;
  }

  .drink-category-block .print-category {
    break-after: avoid-page;
    page-break-after: avoid;
  }
}

/* ===========================
   RESPONSIVE
=========================== */

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

  .category-filter-select {
    width: 100%;
  }
}

/* ===========================
  DGRAG
=========================== */
.drag-handle {
  cursor: grab;
  width: 30px;
  text-align: center;
}