:root {
    --primary: #e53935;
    --primary-hover: #b71c1c;
    --secondary: #fbc02d;
    --dark: #111111;
    --dark-light: #1f1f1f;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --glass: rgba(17, 17, 17, 0.82);
    --border: rgba(255, 255, 255, 0.1);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --info: #3b82f6;
    --info-soft: rgba(59, 130, 246, 0.12);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-xl: 1.5rem;
    --radius-lg: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--dark);
    color: var(--text-main);
    line-height: 1.6;
    background-image: 
        radial-gradient(at 0% 0%, rgba(229, 57, 53, 0.14) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(251, 192, 45, 0.12) 0px, transparent 50%);
    min-height: 100vh;
}

h1, h2, h3, h4, .font-heading { font-family: 'Outfit', sans-serif; }

a { text-decoration: none; color: inherit; transition: var(--transition); }

img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

/* Horizontal overflow safety net (mobile) */
.container { overflow-x: clip; }

/* Navigation */
nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    font-weight: 500;
    color: var(--text-muted);
}

.nav-link:hover { color: var(--text-main); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(229, 57, 53, 0.35);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(183, 28, 28, 0.35);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Footer */
footer {
    background: var(--dark-light);
    padding: 4rem 0 2rem;
    margin-top: 5rem;
    border-top: 1px solid var(--border);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
    margin-bottom: 4rem;
}

.footer-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.75rem; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--text-main); padding-left: 5px; }

.footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Flash Messages */
.flash {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); border-color: rgba(34, 197, 94, 0.24); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: rgba(239, 68, 68, 0.24); color: var(--danger); }

/* Cart Badge */
.cart-badge {
    position: relative;
}
.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--secondary);
    color: white;
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid var(--dark);
}

@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-inner { flex-wrap: wrap; }
    nav { padding: 0.75rem 0; }
    .logo { font-size: 1.4rem; }
    .btn { padding: 0.6rem 1rem; border-radius: 0.9rem; }
    .cart-count { top: -6px; right: -6px; }
}

/* marketplace-specific */
.hero {
    text-align: center;
    padding: 4rem 0;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    font-weight: 800;
}

.hero p {
    font-size: clamp(1rem, 2.2vw, 1.25rem);
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.grid-tiendas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.card-tienda {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: var(--transition);
}

.card-tienda:hover {
    transform: translateY(-10px);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.tienda-img {
    height: 180px;
    background: var(--dark-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tienda-body {
    padding: 1.5rem;
}

.tienda-nombre {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.tienda-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Product Cards */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.product-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    border-color: var(--secondary);
    transform: scale(1.02);
}

.product-img {
    height: 160px;
    background: var(--dark-light);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    overflow: hidden;
}

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

.product-name {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.product-desc {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--secondary);
}

.badge-unavailable {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
    width: 100%;
}

/* Cart & Checkout */
.cart-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 3rem;
    align-items: start;
}

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

.table-scroll > table {
    min-width: 640px;
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.cart-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.cart-table td {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.cart-total-box {
    background: var(--dark-light);
    padding: 2rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
}

/* Auth forms */
.auth-container {
    max-width: 450px;
    margin: 0 auto;
    padding: 3rem;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: white;
    outline: none;
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Badges for status */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-pendiente { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.24); }
.badge-recogiendo { background: var(--info-soft); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.24); }
.badge-llevando { background: rgba(251, 192, 45, 0.16); color: var(--secondary); border: 1px solid rgba(251, 192, 45, 0.28); }
.badge-entregado { background: var(--success-soft); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.24); }
.badge-cancelado { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.24); }

/* Dashboard layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 3rem;
}

.side-menu {
    list-style: none;
}

.side-menu li {
    margin-bottom: 0.5rem;
}

.side-menu a {
    display: block;
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    color: var(--text-muted);
}

.side-menu a:hover, .side-menu a.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.side-menu a.active {
    color: var(--primary);
    background: rgba(229, 57, 53, 0.16);
    font-weight: 600;
}

/* Shared responsive helpers for public views */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.tienda-header {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 900px) {
    .dashboard-grid { display: flex; flex-direction: column; gap: 1.5rem; }
    .dashboard-grid aside > div:first-child { display: none !important; }
    .side-menu { display: flex; overflow-x: auto; gap: 0.5rem; padding-bottom: 0.5rem; }
    .side-menu::-webkit-scrollbar { display: none; }
    .side-menu li { margin: 0 !important; padding: 0 !important; border: none !important; }
    .side-menu a { display: inline-block; white-space: nowrap; padding: 0.6rem 1rem; border-radius: 20px; }
    .cart-layout { grid-template-columns: 1fr; gap: 1.5rem; }
    .section-header { flex-direction: column; align-items: stretch; }
    .tienda-header { flex-direction: column; align-items: stretch; }
}

@media (max-width: 600px) {
    .container { padding: 0 1rem; }

    .hero { padding: 2.5rem 0; }
    .hero p { margin-bottom: 1.5rem; }
    .hero > div { flex-wrap: wrap; }
    .hero .btn { width: 100%; }

    .nav-inner { flex-direction: column; align-items: stretch; gap: 1rem; }
    .nav-links { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

    .grid-tiendas,
    .menu-grid { gap: 1.25rem; grid-template-columns: 1fr; }

    .tienda-img { height: 140px; }
    .product-img { height: 140px; }

    .cart-layout { grid-template-columns: 1fr; gap: 1rem; }
    .table-scroll > table { min-width: 100%; }
    .cart-table td, .cart-table th { padding: 0.9rem 0.8rem; }

    .cart-total-box { padding: 1.25rem; }
    .auth-container { padding: 1.5rem; }
    .section-header, .tienda-header { gap: 1rem; }
    .product-footer { flex-direction: column; align-items: stretch; gap: 1rem; }
    .cart-item-row { flex-wrap: wrap; gap: 0.75rem !important; }
}

@media (hover: none) and (pointer: coarse) {
    .btn { min-height: 44px; }
}
