:root {
    --font-body: 'Outfit', sans-serif;
    --font-display: 'Playfair Display', serif;

    --color-bg: hsl(30, 20%, 97%);
    --color-surface: hsl(30, 25%, 100%);
    --color-text: hsl(25, 30%, 15%);
    --color-text-muted: hsl(25, 15%, 40%);
    --color-primary: hsl(18, 65%, 42%);
    --color-primary-hover: hsl(18, 65%, 35%);
    --color-border: hsl(30, 20%, 85%);
    --glass-bg: hsla(30, 30%, 100%, 0.6);
    --glass-border: hsla(30, 20%, 80%, 0.5);
    --shadow: 0 4px 20px hsla(25, 30%, 20%, 0.08);
}

[data-theme='dark'] {
    --color-bg: hsl(25, 25%, 8%);
    --color-surface: hsl(25, 20%, 12%);
    --color-text: hsl(30, 20%, 92%);
    --color-text-muted: hsl(30, 10%, 65%);
    --color-primary: hsl(22, 70%, 55%);
    --color-primary-hover: hsl(22, 70%, 62%);
    --color-border: hsl(25, 15%, 22%);
    --glass-bg: hsla(25, 25%, 12%, 0.6);
    --glass-border: hsla(25, 15%, 30%, 0.5);
    --shadow: 0 4px 20px hsla(0, 0%, 0%, 0.35);
}

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

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 2rem;
    border-radius: 0;
}

.logo {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.5rem;
    color: var(--color-text);
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.main-nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-nav a:hover {
    color: var(--color-primary);
}

.cart-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.main-nav .nav-vender {
    color: var(--color-primary);
    font-weight: 700;
}

.main-nav .nav-vender:hover {
    color: var(--color-primary-hover);
}

.cart-badge {
    background: var(--color-primary);
    color: hsl(30, 30%, 97%);
    border-radius: 999px;
    min-width: 1.4rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0 0.35rem;
}

.header-toggles {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-btn:hover {
    transform: translateY(-2px);
}

main {
    flex: 1;
}

.hero {
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-size: cover;
    background-position: center;
    background-color: hsl(25, 30%, 10%);
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, hsla(25, 40%, 5%, 0.35), hsla(25, 40%, 5%, 0.75));
}

.hero-content {
    position: relative;
    max-width: 700px;
    padding: 2rem;
}

/* Regla critica: colores fijos claros sobre el hero oscuro, NO heredan variables del tema
   para que sigan siendo legibles si el usuario activa Light Mode. */
.hero-label,
.hero-title,
.hero-subtitle {
    color: #f4ece6 !important;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.hero-label {
    color: #b8a99a !important;
    display: inline-block;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.hero-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin: 1rem 0;
}

.hero-subtitle {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--color-primary);
    color: hsl(30, 30%, 97%);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
    background: hsla(20, 70%, 50%, 0.1);
    transform: translateY(-2px);
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* El hero siempre tiene una foto oscura de fondo, sin importar el tema
   (ver regla critica de contraste de hero-title/subtitle mas abajo) */
.hero-actions .btn-secondary {
    color: #f4ece6 !important;
    border-color: #f4ece6;
}

.hero-actions .btn-secondary:hover {
    background: rgba(244, 236, 230, 0.15);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 2rem;
}

.auth-form {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 50%;
    align-self: center;
    box-shadow: var(--shadow);
}

.auth-form h1 {
    font-family: var(--font-display);
    font-style: italic;
    text-align: center;
}

.auth-hint {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.auth-hint a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-hint a:hover {
    color: var(--color-primary-hover);
}

.vendedor-banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem 1.3rem;
    border-radius: 16px;
    background: hsla(20, 70%, 50%, 0.12);
    border: 1.5px solid hsla(20, 70%, 50%, 0.45);
    text-decoration: none;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.vendedor-banner:hover {
    background: hsla(20, 70%, 50%, 0.2);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.vendedor-banner-ribbon {
    position: absolute;
    top: 20px;
    right: -38px;
    width: 160px;
    padding: 0.3rem 0;
    background: var(--color-primary);
    color: hsl(30, 30%, 97%);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    transform: rotate(45deg);
}

.vendedor-banner-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
    line-height: 1;
}

.vendedor-banner-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    flex: 1;
    min-width: 0;
}

.vendedor-banner-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
}

.vendedor-banner-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.vendedor-banner-btn {
    margin-top: 0.4rem;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    background: var(--color-primary);
    color: hsl(30, 30%, 97%);
    font-weight: 600;
    font-size: 0.8rem;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.vendedor-banner:hover .vendedor-banner-btn {
    background: var(--color-primary-hover);
}

.vendedor-banner-catalog {
    grid-column: 1 / -1;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.auth-form label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.auth-form input,
.auth-form textarea {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-body);
}

.auth-form textarea {
    min-height: 70px;
    resize: vertical;
}

.auth-form-wide {
    max-width: 560px;
}

.auth-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 0.5rem 0;
}

.flash-container {
    max-width: 1100px;
    margin: 1rem auto 0;
    padding: 0 2rem;
}

.flash {
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.flash-error {
    background: hsla(0, 70%, 50%, 0.15);
    border: 1px solid hsla(0, 70%, 50%, 0.4);
}

.flash-success {
    background: hsla(140, 45%, 40%, 0.15);
    border: 1px solid hsla(140, 45%, 40%, 0.4);
}

.site-footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.footer-credit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-credit:hover {
    color: var(--color-primary);
}

.footer-credit img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

/* Catalogo: filtros */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.5rem 0 2.5rem;
}

.filter-chip {
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-chip:hover {
    color: var(--color-primary);
}

.filter-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: hsl(30, 30%, 97%);
}

/* Grid de productos */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.product-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover {
    transform: translateY(-4px);
}

.product-image {
    height: 180px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.badge-featured {
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
    background: var(--color-primary);
    color: hsl(30, 30%, 97%);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
}

.product-body {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.product-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-primary);
    font-weight: 600;
}

.product-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
}

.product-store {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-decoration: none;
}

.product-store:hover {
    color: var(--color-primary);
}

.product-footer {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.product-price {
    font-weight: 700;
    font-size: 1.1rem;
}

.btn-add-cart {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
}

.btn-add-cart.added {
    background: hsl(140, 45%, 40%);
}

/* Directorio de tiendas */
.tienda-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.tienda-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tienda-card:hover {
    transform: translateY(-4px);
}

.tienda-card-image {
    height: 150px;
    background-size: cover;
    background-position: center;
}

.tienda-card-body {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.tienda-card-sector {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-primary);
    font-weight: 600;
}

.tienda-card-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
}

.tienda-card-location {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.tienda-card-desc {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    flex: 1;
}

.tienda-card-footer {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.tienda-card-count {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.tienda-card-soon {
    font-style: italic;
}

/* Perfil de tienda */
.tienda-header {
    padding: 2rem;
    margin-bottom: 2rem;
}

.tienda-header h1 {
    font-family: var(--font-display);
    font-style: italic;
    margin-bottom: 0.4rem;
}

.tienda-ubicacion {
    color: var(--color-primary);
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
}

.tienda-descripcion {
    color: var(--color-text-muted);
}

/* Carrito */
.cart-page h1 {
    font-family: var(--font-display);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.cart-groups {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-bottom: 2rem;
}

.cart-empty {
    color: var(--color-text-muted);
}

.cart-store-group {
    padding: 1.5rem;
}

.cart-store-name {
    font-family: var(--font-display);
    font-style: italic;
    margin-bottom: 1rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-border);
}

.cart-item-title {
    flex: 1;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.qty-btn:hover {
    color: var(--color-primary);
}

.cart-item-price {
    min-width: 90px;
    text-align: right;
    font-weight: 600;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

.cart-item-remove:hover {
    color: hsl(0, 70%, 55%);
}

.cart-store-footer {
    text-align: right;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 0.6rem;
}

.cart-summary {
    max-width: 400px;
    margin-left: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    color: var(--color-text-muted);
}

.cart-summary-total {
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.2rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-border);
}

.cart-summary .btn {
    margin-top: 0.6rem;
}

/* Checkout */
.checkout-page h1 {
    font-family: var(--font-display);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.checkout-panel {
    max-width: 480px;
    margin-left: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.payment-methods {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0.6rem 0;
}

.payment-methods legend {
    padding: 0 0.4rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.payment-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

.checkout-error {
    color: hsl(0, 70%, 55%);
    font-size: 0.9rem;
    min-height: 1.2rem;
}

.order-code {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin: 0.3rem 0;
}

.order-total {
    font-weight: 600;
}

.order-status {
    font-weight: 700;
}

.order-status-aprobado {
    color: hsl(140, 45%, 40%);
}

.order-status-en_revision {
    color: hsl(35, 80%, 45%);
}

.order-status-pendiente {
    color: var(--color-text-muted);
}

.checkout-page > .btn {
    margin-top: 1.5rem;
}

/* Dashboard vendedor / admin */
.dashboard-page h1 {
    font-family: var(--font-display);
    font-style: italic;
    margin-bottom: 1rem;
}

.dashboard-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.8rem;
}

.dashboard-nav-link {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-nav-link:hover {
    color: var(--color-primary);
}

.dashboard-nav-link.active {
    background: var(--color-primary);
    color: hsl(30, 30%, 97%);
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.stat-value {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 2rem;
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.dashboard-toolbar {
    margin-bottom: 1.2rem;
}

.table-wrapper {
    overflow-x: auto;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
}

.dashboard-table th,
.dashboard-table td {
    text-align: left;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.dashboard-table th {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-actions {
    display: flex;
    gap: 1rem;
}

.table-actions form {
    display: inline;
}

.link-danger {
    background: none;
    border: none;
    color: hsl(0, 70%, 55%);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    text-decoration: underline;
}

.dashboard-form {
    max-width: 560px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-row label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.form-row input,
.form-row select,
.form-row textarea {
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-body);
}

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

.form-row-inline {
    flex-direction: row;
    gap: 1rem;
}

.form-row-inline > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.pedidos-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pedido-card {
    padding: 1.2rem 1.5rem;
}

.pedido-header {
    display: flex;
    justify-content: space-between;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
}

.pedido-items {
    list-style: none;
    margin-bottom: 0.8rem;
}

.pedido-items li {
    padding: 0.2rem 0;
}

.pedido-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-border);
}

.pedido-total {
    font-weight: 700;
}

.badge-envio {
    font-size: 0.8rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    text-transform: capitalize;
}

.badge-envio-despachado {
    background: hsla(140, 45%, 40%, 0.15);
    border-color: hsla(140, 45%, 40%, 0.4);
    color: hsl(140, 45%, 40%);
}

.badge-envio-vencida {
    background: hsla(0, 70%, 55%, 0.15);
    border-color: hsla(0, 70%, 55%, 0.4);
    color: hsl(0, 70%, 55%);
}

.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    margin-left: auto;
}

.trial-banner {
    background: hsla(35, 80%, 50%, 0.12);
    border: 1px solid hsla(35, 80%, 50%, 0.4);
    color: var(--color-text);
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.trial-banner-vencida {
    background: hsla(0, 70%, 55%, 0.12);
    border-color: hsla(0, 70%, 55%, 0.4);
}

@media (max-width: 768px) {
    .site-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .main-nav {
        justify-content: center;
    }

    .cart-item {
        flex-wrap: wrap;
    }
}
