/* ========================= */
/* Variables & Reset         */
/* ========================= */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --whatsapp: #25D366;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --nav-bg: #c5d2e8;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;

  /* Colores de tipo producto */
  --tipo-AguasYSodas: #00d6c8;
  --tipo-Aperitivos: #10a300;
  --tipo-Cervezas: #c99e02;
  --tipo-Energizantes: #020ade;
  --tipo-Gaseosas: #d90e00;
  --tipo-Jugos: #fc6603;
  --tipo-Varios: gray;
  --tipo-VinosYEspumantes: #800080;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================= */
/* Navigation                */
/* ========================= */
nav {
  background: var(--nav-bg);
  padding: 0.5rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}

.nav-brand {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.nav-brand:hover {
  opacity: 0.8;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  text-decoration: none;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,0.5);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-info {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
}

.cart-icon {
  position: relative;
  font-size: 1.25rem;
}

.cart-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 50%;
  font-weight: 700;
}

/* ========================= */
/* Buttons                   */
/* ========================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-whatsapp { background: var(--whatsapp); color: white; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.3rem 0.5rem; min-width: 32px; justify-content: center; }

.btn-group { display: flex; gap: 0.25rem; align-items: center; }

/* ========================= */
/* Forms                     */
/* ========================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.search-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  width: 250px;
}

.filter-select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.input-sm {
  width: 100px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.input-editable {
  width: 90px;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: right;
}

/* ========================= */
/* Modals                    */
/* ========================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-content.modal-success {
  text-align: center;
}

.modal-content.modal-success h2 {
  color: var(--success);
  margin-bottom: 1rem;
}

.modal-content h2 {
  margin-bottom: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-content form button[type="submit"] {
  align-self: center;
  min-width: 120px;
  text-align: center;
}

/* Carrito cantidad */
.carrito-cantidad {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.carrito-cantidad .btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1rem;
}

.carrito-cantidad strong {
  min-width: 2rem;
  text-align: center;
}

/* Edición masiva de precios */
.edit-mode-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.producto-card .input-editable {
  width: 80px;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.producto-card .input-editable:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
  font-weight: 700;
}

/* ========================= */
/* Views                     */
/* ========================= */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.view { animation: fadeIn 0.2s ease; }

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

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

.view-header h2 {
  font-size: 1.5rem;
}

.view-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ========================= */
/* Home                      */
/* ========================= */
.home-container {
  text-align: center;
  padding: 4rem 1rem;
}

.home-container h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}

.title-icon {
  width: 40px;
  height: 40px;
  vertical-align: middle;
}

.home-subtitle {
  font-size: 1.2rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.home-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.home-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.info-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.info-card p {
  font-size: 0.95rem;
  color: var(--text-light);
  margin: 0.25rem 0;
  line-height: 1.5;
}

/* ========================= */
/* Productos Grid            */
/* ========================= */
.productos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.producto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
  min-height: 160px;
}

.producto-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.tipo-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  align-self: flex-start;
  margin-bottom: 0.25rem;
}

.producto-card .tipo-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  align-self: flex-start;
  margin-bottom: 0.25rem;
}

.producto-card .descripcion {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  margin-bottom: 0.5rem;
}

.producto-card .cantidad-info {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.producto-card .precios {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.producto-card .precios .precio-valor {
  font-weight: 700;
  color: var(--primary);
}

.producto-card .card-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.producto-card .cantidad-carrito {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 0.5rem;
  min-width: 2rem;
  text-align: center;
  color: var(--primary);
}

/* ========================= */
/* Tables                    */
/* ========================= */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table thead {
  background: var(--nav-bg);
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.data-table th {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-light);
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr.entregado {
  opacity: 0.5;
  background: #f1f1f1;
}

.data-table td.text-center {
  text-align: center;
  vertical-align: middle;
}

.data-table th.text-center {
  text-align: center;
  vertical-align: middle;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ========================= */
/* Carrito                   */
/* ========================= */
.carrito-footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1rem;
}

.carrito-total {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
}

.carrito-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ========================= */
/* Alerts & Messages         */
/* ========================= */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
}

.alert-success {
  background: #dcfce7;
  border: 1px solid #16a34a;
  color: #166534;
}

.alert-info {
  background: #dbeafe;
  border: 1px solid #2563eb;
  color: #1e40af;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 0.5rem;
  background: #fef2f2;
  border-radius: 4px;
}

/* ========================= */
/* Toggle Switch             */
/* ========================= */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 22px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* ========================= */
/* Pagination                */
/* ========================= */
.pagination {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  min-width: 36px;
  transition: all 0.2s;
}

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}

.pagination button:hover:not(.active):not(:disabled) {
  background: #e2e8f0;
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination .ellipsis {
  padding: 0.5rem 0.5rem;
  color: var(--text-light);
}

/* ========================= */
/* Perfil                    */
/* ========================= */
.perfil-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  max-width: 500px;
}

.perfil-card .field {
  display: flex;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.perfil-card .field-label {
  font-weight: 600;
  width: 120px;
  color: var(--text-light);
  font-size: 0.85rem;
}

.perfil-card .field-value {
  flex: 1;
}

/* ========================= */
/* Footer                    */
/* ========================= */
footer {
  background: gainsboro;
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: auto;
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.instagram-link {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  transition: transform 0.2s;
}

.instagram-link:hover {
  transform: scale(1.1);
}

.instagram-icon {
  width: 28px;
  height: 28px;
}

.footer-info {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  text-align: left;
  flex: 1;
}

.footer-social {
  display: flex;
  gap: 0.5rem;
}

.footer-social a {
  text-decoration: none;
  font-size: 1.5rem;
  transition: transform 0.2s;
}

.footer-social a:hover {
  transform: scale(1.2);
}

.footer-credits {
  text-align: right;
  font-size: 0.8rem;
}

.footer-credits a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.footer-credits a:hover {
  text-decoration: underline;
}

/* ========================= */
/* Empty State               */
/* ========================= */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ========================= */
/* Contacto                  */
/* ========================= */
.contacto-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

.contacto-content h5 {
  color: var(--text);
}

.contacto-content p {
  color: var(--text-light);
  line-height: 1.8;
}

.contacto-content a {
  transition: opacity 0.2s;
}

.contacto-content a:hover {
  opacity: 0.8;
}

/* ========================= */
/* Responsive                */
/* ========================= */
@media (max-width: 768px) {
  nav {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  main {
    padding: 1rem;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .view-actions {
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

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

  .form-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .home-container h1 {
    font-size: 1.8rem;
  }

  .home-actions {
    flex-direction: column;
  }

  .home-info {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .footer-container {
    flex-direction: column;
    text-align: center;
  }

  .footer-info {
    order: 1;
    justify-content: center;
    text-align: center;
  }

  .footer-credits {
    order: 2;
    text-align: center;
  }

  .data-table {
    font-size: 0.8rem;
  }

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

  .carrito-actions {
    flex-direction: column;
  }
}
