/**
 * ESTILOS MODERNOS PARA AUTOGESTIÓN DE CLIENTES
 * Diseño profesional y responsive para móviles y escritorio
 * Compatible con Bootstrap 4.4.1
 */

/* ============================================
   VARIABLES Y COLORES MODERNOS
   ============================================ */
:root {
    --primary-color: #4A90E2;
    --primary-dark: #2E5C8A;
    --primary-light: #7AB5F5;
    --secondary-color: #50C878;
    --accent-color: #F39C12;
    --danger-color: #E74C3C;
    --warning-color: #F1C40F;
    --success-color: #2ECC71;
    --info-color: #3498DB;
    --dark-color: #2C3E50;
    --light-color: #ECF0F1;
    --gray-color: #95A5A6;
    --white: #FFFFFF;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* ============================================
   TIPOGRAFÍA MEJORADA
   ============================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    color: var(--dark-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 1rem;
}

h5 {
    font-size: 1.25rem;
    font-weight: 600;
}

h6 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.container-fluid.my-4 {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem !important;
    margin-bottom: 2rem !important;
}

.bg-white {
    background-color: var(--white) !important;
}

/* ============================================
   CABECERA DE LA PÁGINA
   ============================================ */
.page-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 1rem 1.5rem;
    margin: -1rem -1.5rem 2rem -1.5rem;
    border-bottom: 2px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 0;
}

.header-logo {
    display: flex;
    align-items: center;
}

.header-logo img {
    max-width: 180px;
    height: auto;
    transition: var(--transition);
}

.header-logo img:hover {
    transform: scale(1.05);
}

/* Compatibilidad con código antiguo */
.d-flex.justify-content-between img,
.d-flex.justify-content-lg-between img {
    max-width: 180px;
    height: auto;
    transition: var(--transition);
}

.d-flex.justify-content-between img:hover,
.d-flex.justify-content-lg-between img:hover {
    transform: scale(1.05);
}

/* ============================================
   SELECTOR DE IDIOMAS MEJORADO
   ============================================ */
.nav-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.nav-pills .nav-item {
    margin: 0 2px;
    display: inline-block;
}

.nav-pills .btn {
    border-radius: var(--border-radius) !important;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.nav-pills .btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
}

.nav-pills .btn-link {
    background-color: var(--white);
    border: 2px solid var(--light-color);
    color: var(--dark-color);
}

.nav-pills .btn-link:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Dropdown de idiomas en móvil */
.dropdown-toggle {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow-sm);
    position: relative;
    min-width: 50px;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Reemplazar texto "Idioma" con ícono de globo en móvil */
.dropdown-toggle::before {
    content: "🌐";
    font-size: 1.2rem;
    margin-right: 0.25rem;
}

/* Ocultar el texto "Idioma" en el dropdown */
#dropdownMenuButton {
    font-size: 0;
}

#dropdownMenuButton::before {
    font-size: 1.2rem;
}

#dropdownMenuButton::after {
    font-size: 0.875rem;
}

.dropdown-menu {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--light-color);
    min-width: 3.5rem;
}

.dropdown-item:hover {
    background-color: var(--light-color);
}

/* Asegurar que el botón de Historial de Pedidos sea visible en móvil */
.nav-item.me-1 {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.nav-item.me-1 a,
.nav-item.me-1 .btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

/* ============================================
   ALERTAS MEJORADAS
   ============================================ */
.alert {
    border-radius: var(--border-radius);
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

.alert-info {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-left-color: var(--info-color);
    color: #1565C0;
}

.alert h4 {
    font-weight: 600;
    margin-bottom: 0;
}

/* ============================================
   BOTONES PRINCIPALES MODERNOS
   ============================================ */
.btn {
    border-radius: var(--border-radius);
    padding: 0.625rem 1.5rem;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    position: relative;
    overflow: hidden;
    color: var(--white) !important; /* Texto blanco para mejor contraste */
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0);
    transition: var(--transition);
}

.btn-primary:hover::before {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.18);
    color: var(--white) !important; /* Mantener texto blanco en hover */
}

.btn-primary:active {
    box-shadow: var(--shadow-sm);
    transform: scale(0.98);
}

.btn.w-100 {
    margin-bottom: 1rem;
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
}

/* Iconos en botones */
.btn i {
    margin-right: 0.5rem;
}

/* ============================================
   SECCIONES COLAPSABLES (CARDS)
   ============================================ */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.card-body {
    padding: 2rem;
}

/* Eliminar animación de parpadeo al abrir colapsables */
.collapse {
    transition: none;
}

.collapsing {
    transition: height 0.35s ease;
}

/* ============================================
   TABLAS RESPONSIVE Y MODERNAS
   ============================================ */
.table-responsive-sm {
    border-radius: var(--border-radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
}

.table {
    margin-bottom: 0;
}

.table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.table thead th {
    border: none;
    padding: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: var(--transition);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(74, 144, 226, 0.05);
}

.table-hover tbody tr:hover {
    background-color: rgba(74, 144, 226, 0.1);
    transform: scale(1.01);
    box-shadow: var(--shadow-sm);
}

.table td, .table th {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--light-color);
}

/* Tabla de otros pedidos */
.table td a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.table td a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Estados de pedido */
.table td:last-child a.btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ============================================
   FORMULARIOS MEJORADOS
   ============================================ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-control,
.custom-select {
    border-radius: var(--border-radius);
    border: 2px solid var(--light-color);
    padding: 0.75rem 1rem;
    transition: var(--transition);
    font-size: 1rem;
    line-height: 1.5;
    min-height: calc(1.5em + 1.5rem + 4px); /* Para asegurar altura adecuada */
}

.custom-select {
    padding-right: 2.5rem; /* Espacio para la flecha del select */
    background-position: right 0.75rem center;
}

.form-control:focus,
.custom-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
    outline: none;
}

.form-control::placeholder {
    color: var(--gray-color);
    opacity: 0.7;
}

label.col-form-label {
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* Custom file input */
.custom-file-label {
    border-radius: var(--border-radius);
    border: 2px solid var(--light-color);
}

.custom-file-input:focus ~ .custom-file-label {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
}

/* ============================================
   CHECKBOXES Y PRODUCTOS
   ============================================ */
.border-bottom {
    border-bottom: 2px solid var(--light-color) !important;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.border-bottom:hover {
    background-color: rgba(74, 144, 226, 0.05);
    border-radius: var(--border-radius);
    padding: 1rem;
}

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Imágenes de productos */
img[alt*="producto"],
img[src*="medium_default"] {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

img[alt*="producto"]:hover,
img[src*="medium_default"]:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* ============================================
   PAGINACIÓN
   ============================================ */
.pagination {
    margin-top: 2rem;
}

.page-item .page-link {
    border-radius: var(--border-radius);
    margin: 0 3px;
    color: var(--primary-color);
    border: 2px solid var(--light-color);
    transition: var(--transition);
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-color: var(--primary-color);
}

.page-item .page-link:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* ============================================
   MODAL MEJORADO
   ============================================ */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    border-bottom: none;
}

.modal-title {
    font-weight: 600;
}

.modal-footer {
    border-top: 1px solid var(--light-color);
    padding: 1.25rem;
}

/* ============================================
   BADGES Y ESTADOS
   ============================================ */
.badge {
    padding: 0.5rem 0.875rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.875rem;
}

.badge-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #27AE60 100%);
}

.badge-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #F39C12 100%);
}

.badge-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #C0392B 100%);
}

.badge-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #2980B9 100%);
}

/* ============================================
   RESPONSIVE DESIGN - MÓVILES
   ============================================ */

/* Smartphones pequeños (portrait) */
@media (max-width: 575.98px) {
    .container-fluid.my-4 {
        padding: 1rem !important;
        margin: 0.5rem !important;
        border-radius: 0;
    }

    h5 {
        font-size: 1.1rem;
    }

    h6 {
        font-size: 1rem;
    }

    /* Cabecera más compacta en móvil */
    .page-header {
        padding: 0.75rem 1rem;
        margin: -1rem -1rem 1.5rem -1rem;
    }
    
    .header-logo img {
        max-width: 100px;
    }
    
    /* Logo más pequeño en móvil (compatibilidad) */
    .d-flex.justify-content-between img,
    .d-flex.justify-content-lg-between img {
        max-width: 120px;
    }

    /* Botones de idioma */
    .nav-pills .nav-item {
        margin: 2px;
    }

    .nav-pills .btn {
        padding: 0.5rem !important;
    }

    /* Asegurar que el botón de historial sea visible en móvil */
    .nav-item.me-1 {
        display: inline-block !important;
        margin-right: 0.5rem !important;
    }

    .nav-item.me-1 .btn {
        white-space: nowrap;
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    /* Alertas */
    .alert {
        padding: 1rem;
        font-size: 0.95rem;
    }

    .alert h4 {
        font-size: 1.1rem;
    }

    /* Botones principales */
    .btn.w-100 {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Cards */
    .card-body {
        padding: 1rem;
    }

    /* Tablas - Permitir scroll horizontal en móvil */
    .table-responsive-sm {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
    }

    .table {
        font-size: 0.875rem;
        min-width: 600px; /* Ancho mínimo para permitir scroll */
        white-space: nowrap; /* Evitar que el texto se parta en varias líneas */
    }

    .table td, .table th {
        padding: 0.75rem 0.5rem;
    }

    .table thead th {
        font-size: 0.75rem;
        padding: 0.75rem 0.5rem;
    }

    /* Formularios */
    .form-group.row {
        margin-bottom: 1rem;
    }

    label.col-form-label {
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }

    .form-control,
    .custom-select {
        padding: 0.625rem 0.875rem;
        font-size: 0.95rem;
        line-height: 1.5;
        min-height: calc(1.5em + 1.25rem + 4px);
    }
    
    .custom-select {
        padding-right: 2rem;
    }

    /* Paginación */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-item .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Espaciado entre secciones */
    .mt-4 {
        margin-top: 1rem !important;
    }

    .mb-3 {
        margin-bottom: 1rem !important;
    }

    /* Ocultar imágenes grandes en móvil para mejorar carga */
    .col-12.col-md-2 img {
        max-width: 80px;
        margin: 0 auto;
        display: block;
    }
}

/* Smartphones (landscape) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container-fluid.my-4 {
        padding: 1.5rem !important;
    }

    .card-body {
        padding: 1.5rem;
    }

    .table {
        font-size: 0.9rem;
    }
}

/* Tablets (portrait) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container-fluid.my-4 {
        padding: 1.75rem !important;
    }

    .card-body {
        padding: 1.75rem;
    }
}

/* Tablets (landscape) y escritorio pequeño */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container-fluid.my-4 {
        padding: 2rem !important;
    }
}

/* Escritorio grande */
@media (min-width: 1200px) {
    .container-fluid.my-4 {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
    }

    .card-body {
        padding: 2.5rem;
    }
}

/* ============================================
   MEJORAS DE ACCESIBILIDAD
   ============================================ */

/* Focus visible para navegación por teclado */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(74, 144, 226, 0.5);
    outline-offset: 2px;
}

/* Mejora de contraste para textos */
.text-muted {
    color: #6c757d !important;
}

/* ============================================
   ANIMACIONES SUTILES
   ============================================ */

/* Fade in para contenido */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Shake para errores */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* ============================================
   UTILIDADES ADICIONALES
   ============================================ */

/* Sombras personalizadas */
.shadow-sm-custom {
    box-shadow: var(--shadow-sm) !important;
}

.shadow-md-custom {
    box-shadow: var(--shadow-md) !important;
}

.shadow-lg-custom {
    box-shadow: var(--shadow-lg) !important;
}

/* Bordes redondeados */
.rounded-custom {
    border-radius: var(--border-radius) !important;
}

/* Gradientes de fondo */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important;
}

.bg-gradient-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #27AE60 100%) !important;
}

/* Separadores visuales */
.separator {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    margin: 2rem 0;
}

/* Loading spinner */
.spinner-custom {
    border: 3px solid var(--light-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   IMPRESIÓN
   ============================================ */
@media print {
    .nav-pills,
    .btn,
    button {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }

    .table {
        box-shadow: none !important;
    }

    body {
        background: white !important;
    }

    .container-fluid.my-4 {
        background: white !important;
        box-shadow: none !important;
    }
}

/* ============================================
   DARK MODE (Preparado para futuro)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Si en el futuro se quiere implementar modo oscuro */
    /* Las variables se pueden redefinir aquí */
}

