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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-900);
    line-height: 1.6;
    background: var(--gray-50);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* Botones */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-block { display: block; width: 100%; }

/* Formularios */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-error { color: var(--danger); font-size: 13px; margin-top: 4px; display: block; }
.form-card {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 600px;
}
.form-actions { display: flex; gap: 12px; margin-top: 20px; }
.inline-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
}
.inline-form input { flex: 1; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; }

/* Alertas */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-exito { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: var(--gray-200); color: var(--gray-500); }
.badge-nuevo { background: #dbeafe; color: #1e40af; }
.badge-preparando { background: #fef3c7; color: #92400e; }
.badge-listo { background: #dcfce7; color: #166534; }
.badge-entregado { background: var(--gray-200); color: var(--gray-500); }
.badge-cancelado { background: #fef2f2; color: #991b1b; }

/* Tablas */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}
.table th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); }
.table .actions { white-space: nowrap; }
.table .actions .btn { margin-right: 4px; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.no-image { color: var(--gray-500); font-size: 12px; }

/* Paginacion */
.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    background: #fff;
    border: 1px solid var(--gray-200);
}
.tab:hover { text-decoration: none; background: var(--gray-100); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Secciones */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--gray-500);
}
.empty-state .btn { margin-top: 16px; }
.text-muted { color: var(--gray-500); font-size: 14px; margin-top: 8px; }

/* ===== LANDING ===== */
.landing-body { background: #fff; }
.landing-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    max-width: 1100px;
    margin: 0 auto;
}
.landing-logo { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.landing-logo:hover { text-decoration: none; }
.landing-nav-links { display: flex; gap: 16px; align-items: center; }
.landing-nav-links a { font-size: 14px; }
.landing-footer { text-align: center; padding: 32px; color: var(--gray-500); font-size: 14px; }

.hero {
    text-align: center;
    padding: 80px 24px 60px;
    max-width: 700px;
    margin: 0 auto;
}
.hero h1 { font-size: 36px; line-height: 1.2; margin-bottom: 16px; color: var(--gray-900); }
.hero p { font-size: 18px; color: var(--gray-500); margin-bottom: 32px; }

.features { padding: 40px 24px 60px; max-width: 1100px; margin: 0 auto; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.feature-card {
    background: var(--gray-50);
    padding: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.feature-card h3 { margin-bottom: 8px; }
.feature-card p { color: var(--gray-500); font-size: 15px; }

.cta {
    text-align: center;
    padding: 60px 24px;
    background: var(--gray-50);
}
.cta h2 { margin-bottom: 12px; }
.cta p { color: var(--gray-500); margin-bottom: 24px; }

/* ===== AUTH ===== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 24px;
}
.auth-card {
    background: #fff;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}
.auth-card h2 { margin-bottom: 24px; text-align: center; }
.auth-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--gray-500); }

/* ===== PANEL ===== */
.panel-body { background: var(--gray-100); }
.panel-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header h2 { font-size: 16px; font-weight: 600; }
.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-link {
    display: block;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    transition: background 0.2s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }
.sidebar-link.active { background: rgba(255,255,255,0.15); color: #fff; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
}
.sidebar-user { display: block; margin-bottom: 8px; color: rgba(255,255,255,0.7); }
.btn-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}
.btn-logout:hover { color: #fff; }

.panel-main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}
.panel-header {
    background: #fff;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}
.panel-header h1 { font-size: 20px; }
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-700);
}
.panel-content { padding: 24px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-numero { display: block; font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { display: block; font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* Dashboard */
.dashboard-section {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.dashboard-section h3 { margin-bottom: 12px; }
.tienda-link-box { display: flex; gap: 8px; }
.tienda-link-box input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--gray-50);
}

/* Pedido detalle */
.pedido-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.pedido-info-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.pedido-info-card h3 { margin-bottom: 12px; font-size: 16px; }
.pedido-info-card p { margin-bottom: 6px; font-size: 14px; }
.estado-form { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.estado-form select { padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; }

.current-image { margin-bottom: 8px; }

/* ===== TIENDA PUBLICA ===== */
.tienda-body { background: var(--gray-50); }
.tienda-header { background: #fff; border-bottom: 1px solid var(--gray-200); padding: 20px 24px; }
.tienda-header-inner { max-width: 900px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.tienda-logo-img { width: 60px; height: 60px; object-fit: cover; border-radius: 50%; }
.tienda-nombre { font-size: 22px; }
.tienda-telefono { color: var(--gray-500); font-size: 14px; }
.tienda-main { max-width: 900px; margin: 0 auto; padding: 24px; }
.tienda-footer { text-align: center; padding: 24px; color: var(--gray-500); font-size: 13px; }

.catalogo-seccion { margin-bottom: 32px; }
.catalogo-categoria { font-size: 20px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--gray-200); }

.productos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.producto-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.producto-card:hover { box-shadow: var(--shadow-lg); }
.producto-img { width: 100%; height: 180px; object-fit: cover; }
.producto-img-placeholder { width: 100%; height: 180px; background: var(--gray-200); }
.producto-info { padding: 12px; }
.producto-info h3 { font-size: 15px; margin-bottom: 4px; }
.producto-desc { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.producto-precio { font-weight: 700; color: var(--primary); font-size: 16px; display: block; margin-bottom: 8px; }
.producto-card-link { display: block; text-decoration: none; color: inherit; }
.producto-card-link:hover { text-decoration: none; }
.producto-actions { padding: 0 12px 12px; }
.btn-agregar { width: 100%; }

/* Breadcrumb */
.producto-breadcrumb { font-size: 14px; color: var(--gray-500); margin-bottom: 20px; }
.producto-breadcrumb a { color: var(--primary); }
.breadcrumb-sep { margin: 0 6px; }

/* Detalle de producto */
.producto-detalle-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.producto-detalle-imagen { position: relative; }
.producto-detalle-img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    display: block;
}
.producto-detalle-img-placeholder {
    width: 100%;
    height: 300px;
    background: var(--gray-200);
}
.producto-detalle-info { padding: 24px; }
.producto-detalle-categoria {
    display: inline-block;
    padding: 4px 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
}
.producto-detalle-nombre {
    font-size: 24px;
    line-height: 1.3;
    margin-bottom: 12px;
    color: var(--gray-900);
}
.producto-detalle-precio {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}
.producto-detalle-descripcion {
    font-size: 15px;
    line-height: 1.7;
    color: var(--gray-700);
    margin-bottom: 24px;
    white-space: pre-line;
}
.producto-detalle-comprar { margin-top: 8px; }

.cantidad-selector {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 16px;
    width: fit-content;
}
.cantidad-selector button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-300);
    background: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.cantidad-selector button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.cantidad-selector button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.cantidad-selector button:hover { background: var(--gray-100); }
.cantidad-selector span {
    width: 48px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    border-top: 1px solid var(--gray-300);
    border-bottom: 1px solid var(--gray-300);
    background: var(--gray-50);
}

.btn-agregado {
    background: var(--success) !important;
}

/* Galeria de imagenes */
.galeria-principal { position: relative; }
.galeria-miniaturas {
    display: flex;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
}
.galeria-thumb {
    width: 60px;
    height: 60px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
}
.galeria-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.galeria-thumb.active { border-color: var(--primary); }
.galeria-thumb:hover { border-color: var(--gray-300); }
.galeria-thumb.active:hover { border-color: var(--primary); }

/* Imagenes en formulario */
.imagenes-existentes {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.imagen-existente {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}
.imagen-existente img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.imagen-eliminar-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.imagen-eliminar-btn:hover { background: var(--danger); }
.imagenes-preview {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.imagen-preview-item {
    width: 120px;
    text-align: center;
}
.imagen-preview-item img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.imagen-preview-info {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
    word-break: break-all;
}
.form-help {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Productos relacionados */
.productos-relacionados { margin-top: 40px; }
.productos-relacionados h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--gray-900);
}

/* Carrito vacio */
.carrito-vacio {
    text-align: center;
    color: var(--gray-500);
    padding: 24px 0;
    font-size: 14px;
}

/* Carrito item mejorado */
.carrito-item-eliminar {
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 18px;
    cursor: pointer;
    padding: 0 0 0 8px;
    line-height: 1;
}
.carrito-item-eliminar:hover { color: var(--danger); }

/* Carrito */
.carrito-flotante {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 90;
}
.carrito-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 14px 24px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}
.carrito-btn:hover { background: var(--primary-dark); }

.carrito-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}
.carrito-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}
.carrito-header h3 { font-size: 18px; }
.carrito-cerrar { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--gray-500); }
.carrito-items { flex: 1; overflow-y: auto; padding: 16px 20px; }
.carrito-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}
.carrito-item-nombre { flex: 1; }
.carrito-item-qty { display: flex; align-items: center; gap: 8px; }
.carrito-item-qty button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-300);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}
.carrito-total { padding: 12px 20px; border-top: 1px solid var(--gray-200); font-size: 16px; }
.carrito-form { padding: 16px 20px; border-top: 1px solid var(--gray-200); }
.carrito-form input,
.carrito-form textarea,
.carrito-form select {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

/* Error page */
.error-page {
    text-align: center;
    padding: 100px 24px;
}
.error-page h1 { font-size: 72px; color: var(--gray-300); }
.error-page p { color: var(--gray-500); margin: 16px 0 32px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-toggle { display: block; }
    .panel-main { margin-left: 0; }

    .hero h1 { font-size: 28px; }
    .hero p { font-size: 16px; }

    .pedido-info-grid { grid-template-columns: 1fr; }
    .tienda-link-box { flex-direction: column; }

    .productos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .producto-img { height: 140px; }

    .carrito-panel { max-width: 100%; }

    .producto-detalle-nombre { font-size: 20px; }
    .producto-detalle-precio { font-size: 24px; }
    .producto-detalle-info { padding: 16px; }
}

@media (min-width: 600px) {
    .producto-detalle-grid {
        grid-template-columns: 1fr 1fr;
    }
    .producto-detalle-img {
        height: 100%;
        min-height: 350px;
    }
}
