/**
 * Hoja de estilos principal - Cafetería CasaMarx
 * Sistema de tokens heredado de casamarx.com
 */

/* ============================================================
   TOKENS DE COLOR Y TIPOGRAFÍA
   ============================================================ */
:root {
  /* Colores principales */
  --rojo: #6D0A0A;
  --azul: #08273B;
  --amarillo: #CD790B;
  --verde: #3F481B;

  /* Backgrounds */
  --bg: #F2F0EC;
  --bg-2: #E8E5DD;

  /* Textos */
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;

  /* Tipografías */
  --display: 'Barlow Condensed', sans-serif;
  --body: 'Source Sans 3', sans-serif;
  --mono: 'JetBrains Mono', monospace;

  /* Espaciado */
  --container-max: 1200px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 2rem;
  --spacing-lg: 4rem;

  /* Backgrounds terciarios y decorativos */
  --bg-3: #FDFCFA;
  --line: #CDC8BD;
  --paper: #FFFFFF;
  --radius: 2px;

  /* Breakpoints como variables */
  --bp-sm: 375px;
  --bp-md: 768px;
  --bp-lg: 1024px;

  /* Colores secundarios para hover/estados */
  --rojo-light: #9D2828;
  --amarillo-light: #E89D3C;

  /* Sombras */
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-color-dark: rgba(0, 0, 0, 0.2);
  --shadow-rgb: rgba(109, 10, 10, 0.1);

  /* Bordes transparentes */
  --border-subtle: rgba(0, 0, 0, 0.1);
  --overlay-dark: rgba(0, 0, 0, 0.5);

  /* Estados de error/alerta */
  --alert-error-bg: #fee;
  --alert-error-text: #c33;
  --alert-error-border: #fcc;

  /* Brand colors */
  --whatsapp-green: #25D366;
  --whatsapp-green-hover: #20BA5A;
}

body.dark {
  --bg: #1a1a1a;
  --bg-2: #2a2a2a;
  --text-primary: #f5f5f5;
  --text-secondary: #d0d0d0;
  --rojo: #9D2828;
  --amarillo: #E89D3C;
  --bg-3: #242424;
  --line: #404040;
  --paper: #1a1a1a;
  --rojo-light: #B84848;
  --amarillo-light: #F0A850;

  /* Dark mode overrides */
  --shadow-color: rgba(255, 255, 255, 0.05);
  --shadow-color-dark: rgba(255, 255, 255, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --alert-error-bg: rgba(200, 50, 50, 0.2);
  --alert-error-text: #ff9999;
  --alert-error-border: rgba(200, 50, 50, 0.5);
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-padding-top: 80px;
}

body {
  font-family: var(--body);
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--spacing-sm);
}

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.2;
}

.display-1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  color: var(--rojo);
}

.section-title {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--rojo);
  margin-bottom: var(--spacing-sm);
  font-weight: 600;
  display: block;
}

.lead {
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--text-secondary);
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-block;
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  font-family: var(--display);
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
}

.btn-primary {
  background-color: var(--rojo);
  color: white;
}

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

.btn-secondary {
  background-color: var(--bg-2);
  color: var(--text-primary);
}

.btn-danger {
  background-color: #d32f2f;
  color: white;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
  text-align: center;
}

/* ============================================================
   SECCIONES
   ============================================================ */
section {
  padding: var(--spacing-lg) 0;
  border-bottom: 1px solid var(--line);
}

section:last-of-type {
  border-bottom: none;
}

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

.hero {
  text-align: center;
  padding: var(--spacing-lg) 0;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);
  position: relative;
  overflow: hidden;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero .container {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.hero .display-1 {
  font-size: clamp(2rem, 8vw, 4rem);
  font-family: var(--display);
  font-weight: 700;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.hero .lead {
  font-size: 1.25rem;
  font-family: var(--body);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-lg);
  line-height: 1.6;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--rojo), transparent);
  opacity: 0.05;
  border-radius: 50%;
  z-index: 1;
}

/* ============================================================
   MENÚ
   ============================================================ */
.menu-section {
  background-color: var(--bg);
}

.menu-section .container {
  position: relative;
}

.menu-section .eyebrow {
  text-align: center;
  display: block;
}

.menu-section .section-title {
  text-align: center;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.menu-category {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: var(--spacing-md);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.menu-category:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow-rgb);
  border-color: var(--rojo);
}

.menu-category h3 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  text-transform: uppercase;
  border-bottom: 2px solid var(--rojo);
  padding-bottom: var(--spacing-sm);
}

.menu-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--spacing-md);
}

.menu-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--rojo);
  border-radius: 4px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow-rgb);
}

.menu-card-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background-color: var(--bg-2);
}

.menu-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.menu-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  color: var(--rojo);
  font-size: 4rem;
  font-weight: 700;
  font-family: var(--display);
}

.menu-card-content {
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.menu-card-content h4 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.menu-card-price {
  font-family: var(--mono);
  font-size: 1.125rem;
  color: var(--rojo);
  font-weight: 600;
  margin-top: auto;
}

/* Mantener compatibilidad con estilos antiguos si es necesario */
.menu-items {
  display: grid;
  gap: var(--spacing-sm);
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px dotted var(--line);
}

.menu-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.menu-item-name {
  font-family: var(--body);
  color: var(--text-primary);
  font-weight: 500;
}

.menu-item-price {
  font-family: var(--mono);
  color: var(--rojo);
  font-weight: 600;
  text-align: right;
}

/* ============================================================
   AVISOS
   ============================================================ */
.notices-section {
  background-color: var(--azul);
  color: white;
}

.notices-section .eyebrow {
  color: var(--amarillo);
}

.notices-section .section-title {
  color: white;
}

.notices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.notice-card {
  background-color: var(--amarillo);
  color: var(--text-primary);
  padding: var(--spacing-md);
  border-radius: 8px;
  border-left: 4px solid var(--rojo);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.notice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow-color-dark);
}

.notice-card::before {
  content: '📢';
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.2;
  top: -10px;
  right: -10px;
}

.notice-card h3 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
}

.notice-card p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: var(--spacing-sm);
}

.notice-card .notice-meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--spacing-xs);
}

/* ============================================================
   HORARIOS
   ============================================================ */
.hours-section {
  background-color: var(--bg);
}

.hours-section .section-title {
  text-align: center;
}

.hours-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  max-width: 800px;
  margin: var(--spacing-lg) auto 0;
  align-items: center;
}

.hours-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.hours-item {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: var(--spacing-md);
  border-radius: 8px;
}

.hours-item-day {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--rojo);
  text-transform: uppercase;
  margin-bottom: var(--spacing-xs);
}

.hours-item-time {
  font-family: var(--mono);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.hours-item-closed {
  color: var(--text-secondary);
  opacity: 0.6;
}

.hours-notice {
  background: var(--bg-2);
  padding: var(--spacing-md);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-left: 4px solid var(--amarillo);
}

/* ============================================================
   UBICACIÓN
   ============================================================ */
.location-section {
  background-color: var(--paper);
}

.location-section .section-title {
  text-align: center;
}

.location-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  align-items: start;
  margin-top: var(--spacing-lg);
}

.location-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.address {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
  font-family: var(--body);
  font-weight: 500;
}

.address strong {
  color: var(--rojo);
  font-weight: 700;
}

.metro {
  font-family: var(--mono);
  color: var(--text-secondary);
  font-size: 0.95rem;
  padding: var(--spacing-sm);
  background: var(--bg);
  border-left: 4px solid var(--amarillo);
  padding-left: var(--spacing-md);
}

.map-container {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px var(--shadow-color);
  height: 400px;
}

.map-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ============================================================
   WHATSAPP BUTTON
   ============================================================ */
.whatsapp-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
}

.btn-whatsapp {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 1rem 1.5rem;
  background-color: var(--whatsapp-green);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow-color-dark);
  transition: all 0.3s;
  font-family: var(--display);
}

.btn-whatsapp:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.btn-whatsapp:not(:disabled):hover {
  background-color: var(--whatsapp-green-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow-color-dark);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);
}

.login-box {
  background-color: white;
  padding: var(--spacing-lg);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  width: 100%;
}

body.dark .login-box {
  background-color: var(--bg-2);
}

.login-title {
  text-align: center;
  color: var(--rojo);
  margin-bottom: var(--spacing-xs);
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

.login-form {
  margin-top: var(--spacing-md);
}

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 600;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-family: var(--body);
  font-size: 1rem;
  background-color: var(--bg);
  color: var(--text-primary);
}

.alert {
  padding: var(--spacing-sm);
  border-radius: 4px;
  margin-bottom: var(--spacing-md);
}

.alert-error {
  background-color: var(--alert-error-bg);
  color: var(--alert-error-text);
  border: 1px solid var(--alert-error-border);
}

.login-footer {
  text-align: center;
  margin-top: var(--spacing-md);
}

.login-footer a {
  color: var(--rojo);
  text-decoration: none;
}

/* ============================================================
   ADMIN
   ============================================================ */
.admin-body {
  background-color: var(--bg-2);
}

.admin-header {
  background-color: var(--azul);
  color: white;
  padding: var(--spacing-md) 0;
}

.admin-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1 {
  color: white;
  font-size: 1.75rem;
}

.admin-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.admin-main {
  padding: var(--spacing-lg) 0;
}

.admin-tabs {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--border-subtle);
}

.tab-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  background: none;
  border: none;
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.3s;
}

.tab-btn.active {
  color: var(--rojo);
  border-bottom-color: var(--rojo);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.section-header h2 {
  color: var(--rojo);
}

.admin-list {
  background-color: white;
  border-radius: 8px;
  padding: var(--spacing-md);
}

body.dark .admin-list {
  background-color: var(--bg);
}

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

.admin-table th {
  background-color: var(--bg-2);
  padding: var(--spacing-sm);
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border-subtle);
}

.admin-table td {
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.admin-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
}

.admin-table tbody tr:hover {
  background-color: var(--bg-2);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-dark);
  overflow: auto;
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: var(--spacing-lg);
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
}

body.dark .modal-content {
  background-color: var(--bg-2);
}

.close {
  color: var(--text-secondary);
  float: right;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.close:hover {
  color: var(--rojo);
}

.form-actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
  margin-top: var(--spacing-md);
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--spacing-md);
}

.placeholder {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: var(--spacing-lg);
  background-color: var(--bg-2);
  border-radius: 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: var(--bp-lg)) {
  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .menu-grid-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .notices-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: var(--bp-md)) {
  .section-title {
    font-size: 1.75rem;
  }

  .hero {
    min-height: 50vh;
  }

  .hero .display-1 {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
  }

  .hero .lead {
    font-size: 1rem;
  }

  .menu-grid {
    grid-template-columns: 1fr;
  }

  .menu-grid-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .notices-grid {
    grid-template-columns: 1fr;
  }

  .hours-content {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .location-content {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .map-container {
    height: 300px;
  }

  section {
    padding: var(--spacing-md) 0;
  }

  .admin-header .container {
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: flex-start;
  }

  .admin-actions {
    width: 100%;
    justify-content: space-between;
  }

  .whatsapp-button {
    bottom: 1rem;
    right: 1rem;
  }

  .admin-table {
    font-size: 0.75rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.5rem;
  }

  .admin-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Breakpoint adicional para mobile muy pequeños */
@media (max-width: 480px) {
  .btn {
    font-size: 0.875rem;
    padding: 0.65rem 1rem;
  }

  .container {
    padding: 0 var(--spacing-xs);
  }

  .menu-grid {
    gap: var(--spacing-sm);
  }

  .menu-grid-cards {
    grid-template-columns: 1fr;
  }

  section {
    padding: var(--spacing-md) 0;
  }
}

/* Utility classes - CSP compliant (no inline styles) */
.display-none {
  display: none;
}

.display-inline {
  display: inline;
}

.mb-1 {
  margin-bottom: 1rem;
}

.img-preview {
  max-width: 200px;
  border-radius: 4px;
}

.footer-credit {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}
