/**
 * HonlyCraft Network - Correcciones de Responsividad
 * Asegura que todo se vea bien en pantallas pequeñas
 */

/* ========== Prevenir Overflow Global ========== */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
}

* {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========== Container Responsive ========== */
.container {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 100%;
}

@media (min-width: 576px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ========== Header Responsive ========== */
@media (max-width: 768px) {
    .header {
        height: 300px !important;
    }
    
    .header-top-row {
        padding: 0.75rem 3% !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .header-top-row.scrolled {
        padding: 0.5rem 3% !important;
    }
    
    .btn-header-new {
        padding: 0.5rem 1rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
    }
    
    .btn-header-new i {
        font-size: 0.9rem !important;
    }
    
    .cart-badge {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.75rem !important;
        margin-left: 0.2rem !important;
    }
    
    .logo {
        height: 100px !important;
        margin-top: 80px !important;
    }
    
    .logo-container {
        padding: 0 1rem;
    }
}

@media (max-width: 480px) {
    .header {
        height: 250px !important;
    }
    
    .header-top-row {
        padding: 0.5rem 2% !important;
    }
    
    .btn-header-new {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
    
    .btn-header-new span {
        display: none; /* Ocultar texto en móviles muy pequeños */
    }
    
    .logo {
        height: 80px !important;
        margin-top: 60px !important;
    }
}

/* ========== Grid de Productos Responsive ========== */
.products-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    padding: 0 !important;
}

@media (min-width: 576px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
        gap: 1.25rem !important;
    }
}

@media (min-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
        gap: 1.5rem !important;
    }
}

/* ========== Product Card Responsive ========== */
.product-card {
    max-width: 100%;
    overflow: hidden;
}

.product-content {
    padding: 1rem !important;
}

@media (min-width: 768px) {
    .product-content {
        padding: 1.5rem !important;
    }
}

.product-title {
    font-size: 1.1rem !important;
    line-height: 1.3;
    word-break: break-word;
}

@media (min-width: 768px) {
    .product-title {
        font-size: 1.3rem !important;
    }
}

.product-description {
    font-size: 0.85rem !important;
    -webkit-line-clamp: 2 !important;
}

@media (min-width: 768px) {
    .product-description {
        font-size: 0.95rem !important;
        -webkit-line-clamp: 3 !important;
    }
}

.product-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch !important;
}

@media (min-width: 576px) {
    .product-footer {
        flex-direction: row;
        align-items: center !important;
    }
}

.product-price {
    font-size: 1.3rem !important;
    text-align: center;
}

@media (min-width: 576px) {
    .product-price {
        font-size: 1.6rem !important;
        text-align: left;
    }
}

.btn-add-cart {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem !important;
    font-size: 0.9rem !important;
}

@media (min-width: 576px) {
    .btn-add-cart {
        width: auto;
        padding: 0.75rem 1.5rem !important;
    }
}

.product-badge {
    padding: 0.35rem 0.75rem !important;
    font-size: 0.75rem !important;
}

@media (min-width: 768px) {
    .product-badge {
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
    }
}

/* ========== Cards Responsive ========== */
.card {
    margin-bottom: 1rem !important;
    overflow: hidden;
}

.card-header {
    font-size: 1.1rem !important;
    padding: 1rem !important;
    word-break: break-word;
}

@media (min-width: 768px) {
    .card-header {
        font-size: 1.3rem !important;
        padding: 1.25rem !important;
    }
}

.card-body {
    padding: 1rem !important;
}

@media (min-width: 768px) {
    .card-body {
        padding: 1.5rem !important;
    }
}

/* ========== Botones Responsive ========== */
.btn {
    padding: 0.65rem 1.25rem !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .btn {
        padding: 0.75rem 1.5rem !important;
    }
}

/* Botones en móvil ocupan todo el ancho */
@media (max-width: 576px) {
    .btn:not(.btn-header-new):not(.cart-close) {
        width: 100%;
        justify-content: center;
    }
}

/* ========== Carrito Modal Responsive ========== */
.cart-menu {
    width: 95% !important;
    max-width: 95% !important;
    margin: 1rem auto !important;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

@media (min-width: 576px) {
    .cart-menu {
        width: 90% !important;
        max-width: 500px !important;
        margin: 2rem auto !important;
    }
}

@media (min-width: 768px) {
    .cart-menu {
        width: 45rem !important;
        max-width: 90% !important;
        margin: 5rem auto !important;
    }
}

.cart-menu .cart-header {
    padding: 1rem !important;
    flex-wrap: wrap;
}

@media (min-width: 576px) {
    .cart-menu .cart-header {
        padding: 1.5rem !important;
    }
}

@media (min-width: 768px) {
    .cart-menu .cart-header {
        padding: 1.5rem 2.5rem !important;
    }
}

.cart-menu .cart-header-text {
    font-size: 1.1rem !important;
}

@media (min-width: 576px) {
    .cart-menu .cart-header-text {
        font-size: 1.2rem !important;
    }
}

@media (min-width: 768px) {
    .cart-menu .cart-header-text {
        font-size: 1.4rem !important;
    }
}

.cart-body {
    padding: 1rem !important;
    max-height: 400px !important;
}

@media (min-width: 576px) {
    .cart-body {
        padding: 1.25rem !important;
        max-height: 450px !important;
    }
}

@media (min-width: 768px) {
    .cart-body {
        padding: 1.5rem 2.5rem !important;
        max-height: 500px !important;
    }
}

.cart-footer {
    padding: 1rem !important;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 576px) {
    .cart-footer {
        padding: 1.25rem !important;
        flex-direction: row;
    }
}

@media (min-width: 768px) {
    .cart-footer {
        padding: 1.5rem 2.5rem !important;
    }
}

.cart-menu .name {
    font-size: 0.95rem !important;
    word-break: break-word;
}

@media (min-width: 768px) {
    .cart-menu .name {
        font-size: 1.1rem !important;
    }
}

/* ========== Tablas Responsive ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table {
    min-width: 600px;
    font-size: 0.85rem;
}

@media (min-width: 768px) {
    .table {
        font-size: 0.95rem;
    }
}

.table th,
.table td {
    padding: 0.75rem 0.5rem !important;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .table th,
    .table td {
        padding: 0.75rem !important;
    }
}

/* ========== Forms Responsive ========== */
.form-control {
    font-size: 0.9rem !important;
    padding: 0.65rem 0.85rem !important;
}

@media (min-width: 768px) {
    .form-control {
        font-size: 1rem !important;
        padding: 0.75rem 1rem !important;
    }
}

.input-group {
    flex-wrap: nowrap;
}

.input-group-text {
    font-size: 0.85rem !important;
    padding: 0.65rem 0.85rem !important;
}

@media (min-width: 768px) {
    .input-group-text {
        font-size: 0.95rem !important;
        padding: 0.75rem 1rem !important;
    }
}

/* ========== Sidebar Responsive ========== */
.user-nav-link {
    font-size: 1rem !important;
    padding: 0.85rem 1rem !important;
}

@media (min-width: 768px) {
    .user-nav-link {
        font-size: 1.1rem !important;
        padding: 1rem 1.5rem !important;
    }
}

@media (min-width: 992px) {
    .user-nav-link {
        font-size: 1.2rem !important;
    }
}

/* ========== Alerts Responsive ========== */
.alert {
    padding: 0.75rem 0.75rem 0.75rem 3rem !important;
    font-size: 0.85rem !important;
}

@media (min-width: 768px) {
    .alert {
        padding: 0.75rem 1rem 0.75rem 3.7rem !important;
        font-size: 0.95rem !important;
    }
}

.alert::before {
    min-width: 2.5rem !important;
    max-width: 2.5rem !important;
    padding: 0.6rem !important;
}

@media (min-width: 768px) {
    .alert::before {
        min-width: 2.7rem !important;
        max-width: 2.7rem !important;
        padding: 0.8rem !important;
    }
}

/* ========== Toast Notifications Responsive ========== */
.toast-notification,
.welcome-toast {
    min-width: 280px !important;
    max-width: calc(100vw - 40px) !important;
    padding: 1rem !important;
}

@media (min-width: 576px) {
    .toast-notification,
    .welcome-toast {
        min-width: 320px !important;
        max-width: 380px !important;
        padding: 1.25rem !important;
    }
}

.toast-title {
    font-size: 0.95rem !important;
}

@media (min-width: 576px) {
    .toast-title {
        font-size: 1rem !important;
    }
}

.toast-product {
    font-size: 0.85rem !important;
}

@media (min-width: 576px) {
    .toast-product {
        font-size: 0.9rem !important;
    }
}

/* ========== Row y Col Responsive ========== */
.row {
    margin-left: -0.5rem !important;
    margin-right: -0.5rem !important;
}

@media (min-width: 768px) {
    .row {
        margin-left: -15px !important;
        margin-right: -15px !important;
    }
}

[class*="col-"] {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

@media (min-width: 768px) {
    [class*="col-"] {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* ========== Top Container Responsive ========== */
.top-container {
    margin-top: -50px !important;
}

@media (min-width: 768px) {
    .top-container {
        margin-top: -80px !important;
    }
}

@media (min-width: 992px) {
    .top-container {
        margin-top: -100px !important;
    }
}

/* ========== Footer Responsive ========== */
.footer {
    padding: 2rem 1rem 1rem !important;
}

@media (min-width: 768px) {
    .footer {
        padding: 3rem 2rem 1.5rem !important;
    }
}

.footer-link {
    padding-right: 1rem !important;
    margin-bottom: 1rem !important;
    font-size: 0.85rem !important;
}

@media (min-width: 768px) {
    .footer-link {
        padding-right: 1.8rem !important;
        margin-bottom: 1.5rem !important;
        font-size: 0.95rem !important;
    }
}

.footer-copyright {
    font-size: 0.8rem !important;
    padding: 1rem 0 !important;
}

@media (min-width: 768px) {
    .footer-copyright {
        font-size: 0.9rem !important;
        padding: 1.5rem 0 !important;
    }
}

/* ========== Estadísticas Responsive ========== */
.stat-card {
    padding: 1rem !important;
    flex-direction: column;
    text-align: center;
}

@media (min-width: 576px) {
    .stat-card {
        flex-direction: row;
        text-align: left;
        padding: 1.25rem !important;
    }
}

@media (min-width: 768px) {
    .stat-card {
        padding: 1.5rem !important;
    }
}

.stat-icon {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.3rem !important;
    margin-bottom: 0.75rem;
}

@media (min-width: 576px) {
    .stat-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
        margin-bottom: 0;
    }
}

.stat-value {
    font-size: 1.5rem !important;
}

@media (min-width: 576px) {
    .stat-value {
        font-size: 1.6rem !important;
    }
}

@media (min-width: 768px) {
    .stat-value {
        font-size: 1.8rem !important;
    }
}

.stat-label {
    font-size: 0.8rem !important;
}

@media (min-width: 768px) {
    .stat-label {
        font-size: 0.9rem !important;
    }
}

/* ========== Badges Responsive ========== */
[class*="badge-"] {
    padding: 0.3rem 0.6rem !important;
    font-size: 0.75rem !important;
}

@media (min-width: 768px) {
    [class*="badge-"] {
        padding: 0.35rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
}

.rank-badge {
    width: 25px !important;
    height: 25px !important;
    font-size: 0.8rem !important;
}

@media (min-width: 768px) {
    .rank-badge {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.9rem !important;
    }
}

/* ========== Prevenir Texto que Sobresale ========== */
h1, h2, h3, h4, h5, h6,
p, span, div, a, button {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ========== Imágenes Responsive ========== */
img {
    max-width: 100%;
    height: auto;
}

/* ========== SweetAlert2 Responsive ========== */
.swal2-popup {
    width: calc(100% - 2rem) !important;
    max-width: 500px !important;
    padding: 1.5rem !important;
}

@media (min-width: 768px) {
    .swal2-popup {
        width: auto !important;
        padding: 2rem !important;
    }
}

.swal2-title {
    font-size: 1.3rem !important;
}

@media (min-width: 768px) {
    .swal2-title {
        font-size: 1.5rem !important;
    }
}

.swal2-html-container {
    font-size: 0.9rem !important;
}

@media (min-width: 768px) {
    .swal2-html-container {
        font-size: 1rem !important;
    }
}

/* ========== Utilidades Responsive ========== */
@media (max-width: 576px) {
    .d-sm-none {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .d-md-none {
        display: none !important;
    }
}

@media (max-width: 992px) {
    .d-lg-none {
        display: none !important;
    }
}

/* ========== Espaciado Responsive ========== */
@media (max-width: 576px) {
    .mt-1, .my-1 { margin-top: 0.5rem !important; }
    .mt-2, .my-2 { margin-top: 1rem !important; }
    .mt-3, .my-3 { margin-top: 1.5rem !important; }
    .mb-1, .my-1 { margin-bottom: 0.5rem !important; }
    .mb-2, .my-2 { margin-bottom: 1rem !important; }
    .mb-3, .my-3 { margin-bottom: 1.5rem !important; }
}

/* ========== NOTA: Estilos de username-box movidos a includes/sidebar.php ========== */
/* Los estilos del sidebar ahora están inline para evitar conflictos CSS */
