/* css/styles.css */

/* ========== Reset básico ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f9f9f9;
  color: #333;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: 60px; /* Ajusta según el alto del navbar */
}

/* ========== Navbar ========== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 30px;
  background-color: #077428;
  border-bottom: 1px solid #ddd;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.navbar-left,
.navbar-right {
  display: flex;
  align-items: center;
}

.nav-link {
  margin-left: 20px;
  text-decoration: none;
  color: #333;
  font-weight: 600;
  transition: color 0.3s ease;
}

.navbar-left .nav-link:first-child {
  margin-left: 0;
}

.nav-link:hover,
.nav-link:focus {
  color: #1b4332;
  outline: none;
}

.user-menu {
  position: relative;
}

.user-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #ccc;
  padding: 10px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.user-panel.hidden {
  display: none !important;
}

/* ========== Grid de productos ========== */
.product-grid {
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem;
  flex-grow: 1;
  max-width: 1200px;
  margin: 0 auto;
}

/* Tarjetas de producto */
.product-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  cursor: pointer;
}

.product-card:hover,
.product-card:focus-within {
  transform: translateY(-5px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  outline: none;
}

.product-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.product-content {
  padding: 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-content h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #2a7a4b;
}

.product-content p {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 1rem;
  flex-grow: 1;
}

.price {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1b4332;
  margin-bottom: 1rem;
}

.btn-add-cart {
  background-color: #2a7a4b;
  border: none;
  color: white;
  padding: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.25s ease-in-out;
  user-select: none;
}

.btn-add-cart:hover,
.btn-add-cart:focus {
  background-color: #1b4332;
  outline: none;
}

/* ========== Panel carrito ========== */
.cart-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 350px;
  height: 100%;
  background: white;
  box-shadow: -4px 0 15px rgba(0,0,0,0.2);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.cart-panel.open {
  right: 0;
}

.cart-header {
  background-color: #2a7a4b;
  color: white;
  padding: 1.2rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.cart-header h2 {
  font-size: 1.4rem;
}

.cart-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: white;
  cursor: pointer;
  transition: color 0.25s ease;
}

.cart-close:hover,
.cart-close:focus {
  color: #e63946;
  outline: none;
}

.cart-items {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
}

.cart-items::-webkit-scrollbar {
  width: 6px;
}

.cart-items::-webkit-scrollbar-thumb {
  background-color: #2a7a4b;
  border-radius: 3px;
}

.cart-items p {
  text-align: center;
  color: #555;
  font-style: italic;
}

.cart-item {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #ddd;
  padding-bottom: 1rem;
}

.cart-item-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid #ddd;
}

.cart-item-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cart-item-info h4 {
  color: #2a7a4b;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.cart-item-info p {
  font-size: 0.9rem;
  color: #444;
}

.cart-item-actions {
  margin-top: 0.4rem;
}

.cart-item-actions button {
  background-color: #e63946;
  border: none;
  color: white;
  padding: 4px 8px;
  margin-right: 6px;
  font-size: 0.9rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.25s ease-in-out;
  user-select: none;
}

.cart-item-actions button:hover,
.cart-item-actions button:focus {
  background-color: #9b2d30;
  outline: none;
}

.cart-footer {
  padding: 1rem;
  border-top: 1px solid #ddd;
  background-color: #f1f1f1;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-footer .checkout {
  background-color: #2a7a4b;
  border: none;
  color: white;
  padding: 0.5rem 1.2rem;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.25s ease-in-out;
  user-select: none;
}

.cart-footer .checkout:hover,
.cart-footer .checkout:focus {
  background-color: #1b4332;
  outline: none;
}

/* ========== Footer ========== */
footer {
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
  color: #555;
  background-color: #e7e7e7;
  margin-top: auto;
  user-select: none;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
  .product-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .cart-panel {
    width: 100%;
  }
}

/* ========== Login / Registro ========== */

.form-section {
  max-width: 400px;
  margin: 60px auto;
  padding: 2.5rem 2rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-toggle {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 30px;
}

.form-toggle button {
  flex: 1;
  padding: 12px 0;
  background: #e3e3e3;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.form-toggle button.active {
  background: #2a7a4b;
  color: #fff;
  box-shadow: 0 4px 15px rgba(42, 122, 75, 0.5);
}

form.form {
  display: flex;
  flex-direction: column;
}

form.form input {
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1.8px solid #ccc;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

form.form input:focus {
  outline: none;
  border-color: #2a7a4b;
  box-shadow: 0 0 8px rgba(42, 122, 75, 0.4);
}

form.form label {
  font-weight: 600;
  margin-bottom: 8px;
  color: #444;
}

.btn-primary {
  background-color: #2a7a4b;
  color: #fff;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(42, 122, 75, 0.5);
  transition: background-color 0.3s ease;
}

.btn-primary:hover {
  background-color: #1b4332;
  box-shadow: 0 8px 20px rgba(27, 67, 50, 0.7);
}

.form-container p {
  font-size: 0.9rem;
  color: #666;
  text-align: center;
  margin-top: 15px;
}

.form-container a {
  color: #2a7a4b;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.form-container a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
  .form-section {
    margin: 30px 10px;
    padding: 2rem 1.5rem;
  }
  
  .form-toggle {
    gap: 10px;
  }
  
  .form-toggle button {
    font-size: 0.9rem;
  }
  
  .btn-primary {
    font-size: 1rem;
    padding: 12px;
  }
}


/* Formularios generales */
form.form,
.form-container .form {
  display: none;
  flex-direction: column;
}

form.form.active,
.form-container .form.active {
  display: flex;
}

form.form input,
.form-container input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

form.form input:focus,
.form-container input:focus {
  border-color: #0077cc;
  outline: none;
}

.form-container label {
  margin-top: 1rem;
  font-weight: 600;
}

/* Botón primario */
.btn-primary {
  padding: 0.75rem;
  background-color: #007bff;
  color: white;
  border: none;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  margin-top: 1.5rem;
  transition: background-color 0.3s ease;
  user-select: none;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #0056b3;
  outline: none;
}

/* Panel Usuario */
.user-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.user-panel-content {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  width: 320px;
  max-width: 90%;
  position: relative;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.user-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.user-close:hover,
.user-close:focus {
  color: #e63946;
  outline: none;
}

/* Links y mensajes */
.form-container p {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.form-container a {
  color: #007bff;
  cursor: pointer;
  text-decoration: none;
  transition: text-decoration 0.3s ease;
}

.form-container a:hover,
.form-container a:focus {
  text-decoration: underline;
  outline: none;
}

/* ========== Utilidades ========== */
.hidden {
  display: none !important;
}
