/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #18181B;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

.hidden { display: none !important; }


/* ============================================================
   AUTH PAGE
   ============================================================ */

.page-auth {
  min-height: 100vh;
  background: #F4F4F5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-wrap {
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #09090B;
}

.auth-logo-text span {
  color: #B8973A;
}

.auth-card {
  background: white;
  border-radius: 16px;
  border: 1px solid #E4E4E7;
  padding: 28px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

/* Tab switcher */
.auth-tabs {
  display: flex;
  background: #F4F4F5;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 24px;
  gap: 2px;
}

.auth-tab {
  flex: 1;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #71717A;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  text-align: center;
}

.auth-tab.active {
  background: white;
  color: #09090B;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Form fields */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #3F3F46;
  margin-bottom: 5px;
}

.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #E4E4E7;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #09090B;
  background: #FAFAFA;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}

.field input:focus {
  border-color: #09090B;
  background: white;
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.06);
}

.field input::placeholder {
  color: #A1A1AA;
}

.form-error {
  font-size: 0.8rem;
  color: #EF4444;
  margin-top: 10px;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  font-size: 0.75rem;
  color: #A1A1AA;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #E4E4E7;
}

.btn-google {
  background: white;
  border: 1px solid #E4E4E7;
  color: #3F3F46;
  font-weight: 500;
}

.btn-google:hover {
  background: #F4F4F5;
  border-color: #D4D4D8;
}

.auth-footer-note {
  text-align: center;
  margin-top: 16px;
  font-size: 0.75rem;
  color: #A1A1AA;
}

.auth-footer-note a {
  color: #71717A;
  text-decoration: underline;
}


/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: #09090B;
  color: white;
  border: 1px solid #09090B;
}

.btn-primary:hover {
  background: #27272A;
  border-color: #27272A;
}

.btn-secondary {
  background: transparent;
  border: 1px solid #E4E4E7;
  color: #3F3F46;
}

.btn-secondary:hover {
  background: #F4F4F5;
  border-color: #D4D4D8;
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: #71717A;
}

.btn-ghost:hover {
  color: #09090B;
  background: #F4F4F5;
}

.btn-danger {
  background: transparent;
  border: 1px solid transparent;
  color: #EF4444;
}

.btn-danger:hover {
  background: #FEF2F2;
  border-color: #FECACA;
}

.btn-full {
  width: 100%;
  margin-top: 6px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}


/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: #09090B;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: white;
}

.sidebar-logo span {
  color: #B8973A;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 400;
  color: #A1A1AA;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
  position: relative;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #D4D4D8;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
  font-weight: 500;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 14px;
  background: #B8973A;
  border-radius: 0 2px 2px 0;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 8px 4px;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-help {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
  border-radius: 7px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-help:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
}

.sidebar-help-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-email {
  font-size: 0.72rem;
  color: #71717A;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  font-size: 0.72rem;
  color: #71717A;
  padding: 3px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.btn-logout:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
}


/* --- Main area --- */
.main {
  flex: 1;
  min-width: 0;
  background: #F4F4F5;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  background: white;
  border-bottom: 1px solid #E4E4E7;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-restaurant {
  font-size: 0.875rem;
  font-weight: 600;
  color: #09090B;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Content */
.content {
  flex: 1;
  padding: 28px;
}

/* Page header */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #09090B;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #71717A;
  margin-top: 3px;
}


/* ============================================================
   CARDS
   ============================================================ */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: white;
  border-radius: 12px;
  border: 1px solid #E4E4E7;
  padding: 22px;
  min-width: 0;
}

/* Column spans */
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-12 { grid-column: span 12; }

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

.card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #A1A1AA;
}

.card-link {
  font-size: 0.78rem;
  color: #71717A;
  padding: 3px 8px;
  border-radius: 5px;
  transition: color 0.12s, background 0.12s;
}

.card-link:hover {
  color: #09090B;
  background: #F4F4F5;
}

/* Stat card */
.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #09090B;
  line-height: 1;
  margin-bottom: 5px;
}

.stat-desc {
  font-size: 0.85rem;
  color: #71717A;
}

.stat-sub {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #F4F4F5;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #71717A;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
}

.badge-green {
  background: #DCFCE7;
  color: #15803D;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* QR card */
.qr-body {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.qr-box {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #F4F4F5;
  border: 1px solid #E4E4E7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #A1A1AA;
}

.qr-info {
  flex: 1;
  min-width: 0;
}

.qr-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #F4F4F5;
  border: 1px solid #E4E4E7;
  border-radius: 7px;
  padding: 7px 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.qr-url {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: #3F3F46;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy {
  font-size: 0.72rem;
  color: #71717A;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.btn-copy:hover {
  color: #09090B;
  background: #E4E4E7;
}

.qr-actions {
  display: flex;
  gap: 8px;
}

/* Template card */
.template-grid {
  display: flex;
  gap: 10px;
}

.template-option {
  flex: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}

.template-option.active {
  border-color: #09090B;
}

.template-thumb {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.tmpl-noir    { background: #0A0A0A; color: #B8973A; }
.tmpl-brisa   { background: #F7F5F0; color: #5C7A5F; }
.tmpl-rustico { background: #FDF6EC; color: #C4622D; }
.tmpl-minimal { background: #FFFFFF; color: #0F0F0F; border: 1px solid #E8E8E8; }

.template-label {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 4px;
  background: #F4F4F5;
  color: #3F3F46;
  transition: background 0.15s, color 0.15s;
}

.template-option.active .template-label {
  background: #09090B;
  color: white;
}


/* ============================================================
   DISHES PAGE
   ============================================================ */

.page-actions {
  display: flex;
  gap: 8px;
}

.dishes-table {
  background: white;
  border-radius: 12px;
  border: 1px solid #E4E4E7;
  overflow: hidden;
}

.dishes-table-header {
  display: grid;
  grid-template-columns: 1fr 130px 90px 72px 110px;
  padding: 10px 18px;
  border-bottom: 1px solid #F4F4F5;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #A1A1AA;
}

.dish-row {
  display: grid;
  grid-template-columns: 1fr 130px 90px 72px 110px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #F4F4F5;
  transition: background 0.1s;
}

.dish-row:last-child { border-bottom: none; }

.dish-row:hover { background: #FAFAFA; }

.dish-name {
  font-weight: 500;
  color: #09090B;
  font-size: 0.875rem;
}

.dish-desc {
  font-size: 0.78rem;
  color: #A1A1AA;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.dish-category {
  font-size: 0.8rem;
  color: #71717A;
}

.dish-price {
  font-size: 0.875rem;
  font-weight: 500;
  color: #09090B;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #E4E4E7;
  transition: background 0.2s;
  cursor: pointer;
}

.toggle input:checked + .toggle-track {
  background: #09090B;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

.toggle input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(14px);
}

.dish-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Toggle label (form pages) */
.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.875rem;
  color: #3F3F46;
  user-select: none;
}


/* ============================================================
   FORM PAGE (dishes-new / dishes-edit / settings)
   ============================================================ */

.form-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #E4E4E7;
  padding: 28px;
  max-width: 560px;
}

.form-card .field {
  margin-bottom: 18px;
}

.form-card .field input,
.form-card .field textarea,
.form-card .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #E4E4E7;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #09090B;
  background: #FAFAFA;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}

.form-card .field textarea {
  resize: vertical;
  min-height: 80px;
}

.form-card .field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23A1A1AA' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-card .field input:focus,
.form-card .field textarea:focus,
.form-card .field select:focus {
  border-color: #09090B;
  background: white;
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.06);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #F4F4F5;
}

.form-hint {
  font-size: 0.75rem;
  color: #A1A1AA;
  margin-top: 4px;
}

/* Section title inside form */
.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #09090B;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #F4F4F5;
}

/* Field hint (ej: "sin categorías, crea una primero") */
.field-hint {
  font-size: 0.78rem;
  color: #71717A;
  margin-top: 5px;
}

.field-hint a {
  color: #09090B;
  font-weight: 500;
  text-decoration: underline;
}

/* Add category inline form */
.add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.add-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #E4E4E7;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #09090B;
  background: #FAFAFA;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.add-row input:focus {
  border-color: #09090B;
  background: white;
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.06);
}

.add-row input::placeholder { color: #A1A1AA; }

/* Category list */
.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #F4F4F5;
  transition: background 0.1s;
}

.category-row:last-child { border-bottom: none; }
.category-row:hover { background: #FAFAFA; }

.category-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #09090B;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: #71717A;
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.empty-state-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #3F3F46;
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 0.83rem;
  color: #A1A1AA;
  margin-bottom: 18px;
}

/* Plan banners */
.plan-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.plan-banner .btn { margin-left: auto; white-space: nowrap; flex-shrink: 0; }
.plan-banner--info    { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }
.plan-banner--warning { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.plan-banner--danger  { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }

/* Save feedback */
.save-feedback {
  font-size: 0.8rem;
  font-weight: 500;
  color: #15803D;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.save-feedback.show {
  opacity: 1;
}


/* ============================================================
   HAMBURGER + MOBILE SIDEBAR
   ============================================================ */

.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1.15rem;
  color: #09090B;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}

.btn-hamburger:hover {
  background: #F4F4F5;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
}


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

@media (max-width: 900px) {
  .col-8 { grid-column: span 12; }
  .col-4 { grid-column: span 6; }
  .col-6 { grid-column: span 6; }
}

@media (max-width: 768px) {
  .btn-hamburger { display: flex; }

  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    min-height: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow: hidden;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  .sidebar-overlay.open { display: block; }

  body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .main { padding-bottom: 0; }

  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px; overflow-x: hidden; }

  .col-4, .col-6, .col-8, .col-12 { grid-column: span 12; }

  .qr-body { flex-direction: column; align-items: stretch; }

  .dishes-table-header { display: none; }
  .dish-row { grid-template-columns: 1fr auto auto; gap: 4px; }
  .dish-row > *:nth-child(2),
  .dish-row > *:nth-child(3) { display: none; }

  .field-row { grid-template-columns: 1fr; }

  .form-card { border-radius: 0; border-left: none; border-right: none; }
}

@media (max-width: 480px) {
  .page-title { font-size: 1.2rem; }
  .auth-card { padding: 22px 18px; }
}
