/* ========== RESET Y BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f8fafc;
    color: #111827;
    line-height: 1.4;
    padding-bottom: 80px;
    /* espacio para bottom nav */
}

/* ========== TIPOGRAFÍA ========== */
h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ========== HEADER ========== */
.app-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.4rem;
    background: linear-gradient(135deg, #ff8c3a, #ff6b00);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
}

.offline-indicator {
    background: #ef4444;
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 0.7rem;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.offline-indicator.online {
    background: #10b981;
}

.sync-btn,
.logout-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    padding: 8px 16px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.sync-btn:hover,
.logout-btn:hover {
    background: #ff6b00;
    transform: translateY(-2px);
}

/* ========== CONTENEDOR PRINCIPAL ========== */
.main-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== PANEL DE PRODUCTOS (POS) ========== */
.productos-panel,
.carrito-panel {
    background: white;
    border-radius: 32px;
    box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.08);
    padding: 20px;
    transition: transform 0.2s;
}

.productos-panel:hover,
.carrito-panel:hover {
    transform: translateY(-2px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 18px;
    border-bottom: 2px solid #ffefe3;
    padding-bottom: 12px;
}

.panel-header h2 {
    font-size: 1.5rem;
    color: #1e293b;
}

.admin-btn {
    background: #f1f5f9;
    border: none;
    padding: 8px 20px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.admin-btn:hover {
    background: #ff6b00;
    color: white;
}

/* productos grid */
.productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.producto-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 40px;
    padding: 20px 8px;
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.producto-btn:hover {
    border-color: #ff6b00;
    background: #fff7ed;
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -8px rgba(0, 0, 0, 0.1);
}

/* ========== CARRITO ========== */
.carrito-panel {
    background: white;
}

.carrito-items {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.carrito-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eef2ff;
}

.item-info {
    flex: 2;
    font-weight: 500;
}

.item-cantidad {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cantidad-btn {
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 40px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.1s;
}

.cantidad-btn:active {
    transform: scale(0.92);
}

.item-precio {
    min-width: 80px;
    text-align: right;
    font-weight: 600;
}

.carrito-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.6rem;
    font-weight: 800;
    margin: 16px 0;
    padding-top: 12px;
    border-top: 2px solid #ffefe3;
}

.cobrar-btn {
    background: linear-gradient(135deg, #ff6b00, #e05a00);
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 60px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    box-shadow: 0 8px 20px rgba(255, 107, 0, 0.3);
}

.cobrar-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: center;
    padding: 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.nav-btn {
    background: #1e293b;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.nav-btn:hover {
    background: #ff6b00;
    transform: scale(1.02);
}

/* ========== MODALES ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    margin: auto;
    padding: 28px;
    width: 90%;
    max-width: 600px;
    border-radius: 40px;
    box-shadow: 0 32px 48px -16px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close,
.close-dashboard {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #94a3b8;
}

.close:hover,
.close-dashboard:hover {
    color: #ff6b00;
}

/* formulario admin productos */
#productoForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

#productoForm input {
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 28px;
    font-size: 1rem;
}

#listaProductosAdmin div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    margin: 8px 0;
    padding: 10px 16px;
    border-radius: 60px;
}

/* ========== RESPONSIVE ========== */
@media (min-width: 768px) {
    .main-container {
        flex-direction: row;
        align-items: flex-start;
    }

    .productos-panel {
        flex: 2;
    }

    .carrito-panel {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .producto-btn {
        padding: 14px 4px;
        font-size: 0.85rem;
    }

    .carrito-total {
        font-size: 1.3rem;
    }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 32px;
    padding: 2rem;
    max-width: 90%;
    width: 600px;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.2);
}

/* ========== ADMIN PRODUCTOS – VERSIÓN MÓVIL ========== */

/* Contenedor de cada producto en la lista del admin */
.producto-admin-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-radius: 60px;
  margin: 8px 0;
  padding: 10px 16px;
  transition: all 0.2s;
  flex-wrap: wrap;  /* Permite que los elementos se ajusten en móvil */
  gap: 8px;
}

/* Contenedor de la info del producto (nombre + precio) */
.producto-admin-item > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 120px;
}

/* Contenedor de los botones de acción */
.producto-admin-item > div:last-child {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Botones individuales */
.producto-admin-item button {
  padding: 6px 14px;
  border-radius: 40px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Ajustes exclusivos para pantallas de celular (ancho menor a 560px) */
@media (max-width: 560px) {
  /* Forzar que cada producto ocupe todo el ancho y los botones se apilen */
  .producto-admin-item {
    flex-direction: column;
    align-items: stretch;
    border-radius: 28px;
    padding: 12px;
  }
  
  /* La información del producto se centra y distribuye */
  .producto-admin-item > div:first-child {
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
  }
  
  /* Los botones ocupan todo el ancho disponible */
  .producto-admin-item > div:last-child {
    justify-content: stretch;
    gap: 12px;
  }
  
  .producto-admin-item button {
    flex: 1;
    text-align: center;
    white-space: normal;
  }

  /* Ajuste del formulario para que los campos ocupen todo el ancho */
  #productoForm {
    flex-direction: column;
  }
  #productoForm input, #productoForm button {
    width: 100%;
  }

  /* Modal más compacto */
  .modal-content {
    padding: 1.2rem;
    width: 95%;
  }
}

/* Para pantallas muy pequeñas (menos de 400px) */
@media (max-width: 400px) {
  .producto-admin-item > div:first-child {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ========== MODAL ADMIN – VERSIÓN MÓVIL (como el dashboard) ========== */

/* Asegurar que el modal de admin tenga scroll vertical y límite de altura */
#adminModal .modal-content {
  max-height: 85vh;
  overflow-y: auto;
  width: 95%;
  max-width: 700px;
  padding: 1.2rem;
}

/* Contenedor de la lista de productos – scroll interno */
#listaProductosAdmin {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Cada producto en la lista – diseño flexible */
.producto-admin-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-radius: 60px;
  padding: 8px 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.producto-admin-item > div:first-child {
  flex: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.producto-admin-item > div:last-child {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.producto-admin-item button {
  padding: 6px 14px;
  border-radius: 40px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Responsive para móviles (ancho menor a 560px) */
@media (max-width: 560px) {
  #adminModal .modal-content {
    padding: 1rem;
    max-height: 90vh;
  }

  .producto-admin-item {
    flex-direction: column;
    align-items: stretch;
    border-radius: 28px;
    padding: 12px;
  }

  .producto-admin-item > div:first-child {
    justify-content: space-between;
    width: 100%;
  }

  .producto-admin-item > div:last-child {
    justify-content: stretch;
    gap: 12px;
  }

  .producto-admin-item button {
    flex: 1;
    text-align: center;
    white-space: normal;
  }

  /* Formulario a ancho completo */
  #productoForm {
    flex-direction: column;
  }
  #productoForm input,
  #productoForm button {
    width: 100%;
  }
}

/* Para pantallas muy pequeñas (menos de 400px) */
@media (max-width: 400px) {
  .producto-admin-item > div:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}