/**
 * Estilos personalizados para el sistema de pedidos
 * Diseño moderno y responsive
 */

:root {
    --primary-color: #dc2626;
    --primary-hover: #b91c1c;
    --primary-dark: #991b1b;
    --primary-light: #fee2e2;
    --primary-lighter: #fef2f2;
    --secondary-color: #f59e0b;
    --secondary-light: #fef3c7;
    --secondary-dark: #d97706;
    --accent-color: #059669;
    --accent-light: #d1fae5;
    --accent-dark: #047857;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --font-primary:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    --shadow-sm: 0 2px 4px rgba(220, 38, 38, 0.08);
    --shadow-md: 0 4px 8px rgba(220, 38, 38, 0.12);
    --shadow-lg: 0 12px 20px rgba(220, 38, 38, 0.15);
    --transition-default: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

/* Estilos generales */
body {
    font-family: var(--font-primary);
    padding-top: calc(56px + 1rem);
    background-color: var(--light-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    body {
        padding-top: calc(56px + 0.5rem);
    }
}

/* Ajuste específico para el dashboard admin */
body.admin-dashboard {
    padding-top: 72px;
}

/* Navegación personalizada */
.navbar {
    box-shadow: var(--shadow-sm);
    background-color: var(--primary-color) !important;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1030;
}

.navbar-brand {
    font-weight: bold;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
}

/* Hero Section */
.hero-section {
    background: var(--primary-color);
    background: #c52020;
    padding: clamp(30px, 8vh, 80px) 0;
    margin-top: -56px;
    padding-top: clamp(80px, 12vh, 150px);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        circle at 30% 20%,
        rgba(245, 158, 11, 0.1) 0%,
        transparent 50%
    );
    pointer-events: none;
}

/* Categorías */
.categoria-titulo {
    color: var(--dark-color);
    border-bottom: 3px solid var(--secondary-color);
    padding-bottom: 10px;
    display: inline-block;
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    position: relative;
}

.categoria-titulo::before {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 30%;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Cards de productos */
.producto-card {
    border: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-default);
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(145deg, #ffffff 0%, #fefefe 100%);
}

.producto-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow:
        0 20px 25px rgba(220, 38, 38, 0.15),
        0 10px 10px rgba(220, 38, 38, 0.04);
    border: 2px solid var(--primary-light);
}

.producto-card .card-img-top {
    height: clamp(150px, 30vw, 200px);
    object-fit: cover;
}

.producto-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.precio-tag {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    font-weight: bold;
    color: var(--primary-color);
    margin-top: auto;
}

.cantidad-input {
    width: 60px !important;
    text-align: center;
}

/* Carrito offcanvas */
.offcanvas {
    width: min(400px, 100vw) !important;
}

.cart-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.cart-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.cart-item-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Botones personalizados */
.btn-primary {
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--primary-hover) 100%
    );
    border: none;
    transition: var(--transition-default);
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.3);
    font-weight: 600;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.875rem;
}

.btn-primary:hover {
    background: linear-gradient(
        135deg,
        var(--primary-hover) 0%,
        var(--primary-dark) 100%
    );
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(220, 38, 38, 0.4);
}

.btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(220, 38, 38, 0.4);
}

/* Badge del carrito */
#cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 23px;
    border-radius: 50%;
    font-size: 10px;
    background: linear-gradient(
        135deg,
        var(--secondary-color) 0%,
        #d97706 100%
    ) !important;
    color: white !important;
    font-weight: bold;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 1px 3px rgba(245, 158, 11, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    z-index: 1040;
    border: 1px solid white;
    animation: pulse-cart 2s infinite;
}

@keyframes pulse-cart {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Formulario de checkout */
.checkout-section {
    background: white;
    padding: clamp(15px, 4vw, 30px);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    margin: 0 auto 1rem;
    max-width: 800px;
    width: 100%;
}

/* Resumen del pedido */
.resumen-pedido {
    background: white;
    border-radius: 10px;
    padding: clamp(15px, 4vw, 30px);
    box-shadow: var(--shadow-md);
    margin: 0 auto 1rem;
    max-width: 800px;
    width: 100%;
}

.resumen-pedido h4 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.resumen-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Estados de pedidos */
.badge {
    padding: 0.5em 0.75em;
    font-size: 0.875em;
    border-radius: 0.25rem;
}

.badge-warning {
    background: linear-gradient(
        135deg,
        var(--secondary-color) 0%,
        #d97706 100%
    );
    color: #fff;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}
.badge-info {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
}
.badge-primary {
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--primary-hover) 100%
    );
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}
.badge-success {
    background: linear-gradient(135deg, var(--accent-color) 0%, #047857 100%);
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}
.badge-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}
.badge-danger {
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--primary-dark) 100%
    );
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

/* Tabla responsive */
.table-responsive {
    margin: 1rem 0;
    border-radius: 5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table th {
    white-space: nowrap;
}

/* Footer */
footer {
    margin-top: auto;
    padding: 2rem 0;
    background: var(--dark-color);
    color: var(--light-color);
}

/* Responsive media queries */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .navbar-nav {
        flex-direction: row;
        justify-content: flex-end;
        width: 100%;
    }

    .nav-item {
        margin-left: 1rem;
    }

    .producto-card {
        margin-bottom: 1rem;
    }

    .cart-item {
        grid-template-columns: 60px 1fr;
        gap: 0.75rem;
    }

    .cart-controls {
        grid-column: 1 / -1;
        justify-content: space-between;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .resumen-item {
        grid-template-columns: 1fr;
    }

    .resumen-item .precio {
        text-align: left;
    }
}

/* Utilidades responsive */
.w-100-mobile {
    width: 100% !important;
}

@media (min-width: 768px) {
    .w-100-mobile {
        width: auto !important;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Estado del local */
#mensaje-estado-local {
    border: none;
    border-radius: 8px;
    font-weight: 500;
}

#mensaje-estado-local i {
    margin-right: 8px;
}

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-open {
    background: linear-gradient(135deg, var(--accent-color) 0%, #047857 100%);
    animation: pulse-green 2s infinite;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.status-closed {
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--primary-dark) 100%
    );
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

@keyframes pulse-green {
    0% {
        opacity: 1;
        box-shadow:
            0 0 0 0 rgba(5, 150, 105, 0.7),
            0 0 0 2px rgba(255, 255, 255, 0.8);
    }
    70% {
        opacity: 0.8;
        box-shadow:
            0 0 0 8px rgba(5, 150, 105, 0),
            0 0 0 2px rgba(255, 255, 255, 0.8);
    }
    100% {
        opacity: 1;
        box-shadow:
            0 0 0 0 rgba(5, 150, 105, 0),
            0 0 0 2px rgba(255, 255, 255, 0.8);
    }
}

/* Botones deshabilitados por local cerrado */
.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
}

.btn-agregar-carrito.disabled i {
    color: #6c757d !important;
}

/* Inputs deshabilitados */
input:disabled {
    background-color: #e9ecef;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Configuración del local - Panel admin */
.config-section {
    background: linear-gradient(145deg, var(--light-color) 0%, #ffffff 100%);
    border-left: 4px solid var(--primary-color);
    border-radius: 0 12px 12px 0;
    margin-bottom: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
}

.config-section:hover {
    border-left-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
    transform: translateX(5px);
}

.config-section h4 {
    color: #495057;
    margin-bottom: 20px;
    font-weight: 600;
}

.config-section h4 i {
    margin-right: 10px;
    color: var(--primary-color);
}

/* Switch personalizado para estado del local */
.form-check-input:checked {
    background: linear-gradient(135deg, var(--accent-color) 0%, #047857 100%);
    border-color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

.form-check-input:checked:focus {
    box-shadow: 0 0 0 0.2rem rgba(5, 150, 105, 0.25);
}

/* Alertas personalizadas */
.alert-success {
    border-left: 4px solid var(--accent-color);
    background: linear-gradient(
        135deg,
        rgba(5, 150, 105, 0.1) 0%,
        rgba(5, 150, 105, 0.05) 100%
    );
    color: #065f46;
}

.alert-danger {
    border-left: 4px solid var(--primary-color);
    background: #fecaca;
    color: var(--primary-dark);
}

.alert-warning {
    border-left: 4px solid var(--secondary-color);
    background: var(--secondary-light);
    color: #92400e;
}

/* Responsive para configuración */
@media (max-width: 768px) {
    .config-section {
        margin: 0 -15px 20px -15px;
        border-radius: 0;
        border-left: none;
        border-top: 4px solid #007bff;
        padding: 15px;
    }

    .config-section:hover {
        border-top-color: var(--primary-hover);
    }
}

/* Mensaje flotante de estado */
.position-fixed {
    z-index: 1050;
}

/* Animaciones para transiciones de estado */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Productos no disponibles */
.producto-card.no-disponible {
    position: relative;
    opacity: 0.8;
}

.producto-card.no-disponible .card-body {
    background-color: #f8f9fa;
}

.producto-card.no-disponible .precio-tag {
    color: #6c757d !important;
    text-decoration: line-through;
}

.producto-card.no-disponible:hover {
    transform: none;
    cursor: not-allowed;
}

/* Efectos de hover mejorados para elementos interactivos */
.btn,
.card,
.producto-card,
.badge {
    transition: var(--transition-default);
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn:not(:disabled):active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

/* Animaciones de carga */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Efectos de focus mejorados */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(220, 38, 38, 0.15);
    transform: scale(1.01);
}

/* Mejoras en la navegación */
.navbar-nav .nav-link {
    position: relative;
    transition: var(--transition-default);
}

.navbar-nav .nav-link:hover {
    transform: translateY(-1px);
}

.navbar-nav .nav-link::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--secondary-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after {
    width: 80%;
}

/* Efectos de scroll suaves */
html {
    scroll-behavior: smooth;
}

/* Mejoras en las sombras con el nuevo color */
.shadow-primary {
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.3) !important;
}

.shadow-primary-lg {
    box-shadow: 0 10px 15px rgba(220, 38, 38, 0.4) !important;
}

/* Bordes con degradado */
.border-gradient {
    border: 2px solid;
    border-image: linear-gradient(
            135deg,
            var(--primary-color) 0%,
            var(--secondary-color) 100%
        )
        1;
    border-radius: 8px;
}

/* Texto con degradado */
.text-gradient {
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--primary-dark) 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* Efectos de selección */
::selection {
    background: var(--primary-light);
    color: var(--primary-dark);
}

::-moz-selection {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Lazy Loading de Imágenes */
img[data-src] {
    transition:
        opacity 0.3s ease,
        filter 0.3s ease;
    background-color: var(--gray-100);
    background-image:
        linear-gradient(45deg, var(--gray-100) 25%, transparent 25%),
        linear-gradient(-45deg, var(--gray-100) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--gray-100) 75%),
        linear-gradient(-45deg, transparent 75%, var(--gray-100) 75%);
    background-size: 20px 20px;
    background-position:
        0 0,
        0 10px,
        10px -10px,
        -10px 0px;
}

.lazy-loading {
    opacity: 0.7;
    filter: blur(2px);
}

.lazy-loaded {
    opacity: 1;
    filter: none;
    background-image: none;
    background-color: transparent;
}

.lazy-error {
    opacity: 0.5;
    background-color: var(--gray-200);
    background-image: none;
    position: relative;
}

.lazy-error::after {
    content: "⚠";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--gray-600);
    font-size: 1.5rem;
    z-index: 1;
}

/* Estilos específicos para imágenes de productos */
.card-img-top[data-src] {
    height: 200px;
    object-fit: cover;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.card-img-top.lazy-loading {
    background-color: var(--gray-50);
}

.card-img-top.lazy-loaded {
    animation: fadeInImage 0.5s ease-in-out;
}

@keyframes fadeInImage {
    from {
        opacity: 0;
        transform: scale(1.05);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Placeholder SVG optimización */
.card-img-top[src*="data:image/svg+xml"] {
    background: linear-gradient(
        135deg,
        var(--gray-50) 0%,
        var(--gray-100) 100%
    );
    border: 1px solid var(--gray-200);
}

/* Responsive para lazy loading */
@media (max-width: 768px) {
    .card-img-top[data-src] {
        height: 180px;
    }

    img[data-src] {
        background-size: 15px 15px;
        background-position:
            0 0,
            0 7.5px,
            7.5px -7.5px,
            -7.5px 0px;
    }
}

@media (max-width: 576px) {
    .card-img-top[data-src] {
        height: 160px;
    }
}

/* Imprimir */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        padding: 0;
        margin: 0;
    }

    .container {
        max-width: 100%;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Asegurar que las imágenes se impriman correctamente */
    img[data-src] {
        opacity: 1 !important;
        filter: none !important;
    }
}

/* ===== LAZY LOADING STYLES ===== */

/* Imágenes con lazy loading */
img[data-src] {
    transition:
        opacity 0.3s ease-in-out,
        filter 0.3s ease-in-out;
    background-color: #f8f9fa;
    background-image:
        linear-gradient(45deg, #e9ecef 25%, transparent 25%),
        linear-gradient(-45deg, #e9ecef 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e9ecef 75%),
        linear-gradient(-45deg, transparent 75%, #e9ecef 75%);
    background-size: 20px 20px;
    background-position:
        0 0,
        0 10px,
        10px -10px,
        -10px 0px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Estado de carga */
img.lazy-loading {
    opacity: 0.7;
    filter: blur(2px);
}

/* Estado cargado */
img.lazy-loaded {
    opacity: 1;
    filter: none;
    background: none;
    animation: fadeIn 0.4s ease-in-out;
}

/* Estado de error */
img.lazy-error {
    opacity: 0.8;
    filter: grayscale(50%);
    background: #f8f9fa
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="%23dc2626"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>')
        no-repeat center center;
    background-size: 48px 48px;
}

/* Animación de aparición */
@keyframes fadeIn {
    from {
        opacity: 0.7;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Estilos específicos para imágenes de productos */
.producto-card img[data-src],
.card-img-top[data-src] {
    border-radius: 8px 8px 0 0;
    object-fit: cover;
    width: 100%;
    height: 200px;
}

/* Loading skeleton para imágenes de productos */
.producto-card img[data-src]:not(.lazy-loaded):not(.lazy-error) {
    position: relative;
    overflow: hidden;
}

.producto-card img[data-src]:not(.lazy-loaded):not(.lazy-error)::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.6),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Mejoras para móviles */
@media (max-width: 768px) {
    .producto-card img[data-src],
    .card-img-top[data-src] {
        height: 160px;
    }

    img[data-src] {
        min-height: 160px;
        background-size: 16px 16px;
        background-position:
            0 0,
            0 8px,
            8px -8px,
            -8px 0px;
    }
}

/* Estados para diferentes tipos de carga */
.lazy-placeholder {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%);
    background-size: 200% 200%;
    animation: gradientShift 2s ease-in-out infinite;
}

@keyframes gradientShift {
    0%,
    100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Fallback para navegadores sin soporte */
@supports not (loading: lazy) {
    img[data-src] {
        opacity: 1;
        filter: none;
    }
}
