/* ========================================
   MOBILE.CSS - Solución Definitiva
   ======================================== */

/* === RESET === */
* {
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* === CENTRADO GLOBAL === */
.container {
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
}

.container-fluid {
    padding-left: 20px !important;
    padding-right: 20px !important;
}

main,
#main-content,
.flex-fill {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.py-4 {
    max-width: 1400px;
    margin: 0 auto;
}

.row {
    margin-left: auto;
    margin-right: auto;
}

/* === HEADER DESKTOP === */
.header {
    width: 100%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container-fluid {
    padding: 12px 20px;
}

.header .d_flex {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Logo */
.header a img {
    max-width: 70px;
    height: auto;
}

/* Botones desktop */
.tomi_btn {
    padding: 10px 15px;
    margin: 0 3px;
    font-size: 13px;
    white-space: nowrap;
}

.tomi_btn i {
    margin-right: 5px;
}

/* Menú hamburguesa - oculto en desktop */
#mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    flex-direction: column;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    padding: 8px 10px;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#mobile-menu-toggle span {
    width: 22px;
    height: 2.5px;
    background-color: #333;
    margin: 2.5px 0;
    transition: 0.3s;
    border-radius: 2px;
}

#mobile-menu-toggle.active {
    background: #333;
    border-color: #333;
}

#mobile-menu-toggle.active span {
    background-color: #fff;
}

#mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-4px, 5px);
}

#mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

#mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(45deg) translate(-4px, -5px);
}

/* Logo móvil fijo */
#mobile-logo {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10001;
    background: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#mobile-logo img {
    max-width: 45px;
    height: auto;
    display: block;
}

/* Menú móvil lateral */
#mobile-nav {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    z-index: 9999;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding: 20px 15px;
}

#mobile-nav.active {
    left: 0;
}

#mobile-nav .tomi_btn {
    display: block;
    width: 100%;
    padding: 16px 20px;
    margin: 8px 0;
    text-align: left;
    font-size: 15px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s ease;
}

#mobile-nav .tomi_btn:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

#mobile-nav .tomi_btn a {
    display: flex;
    align-items: center;
    width: 100%;
    color: #333;
}

#mobile-nav .tomi_btn i {
    margin-right: 12px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* Overlay */
#mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: none;
}

#mobile-overlay.active {
    display: block;
}

/* === TÍTULOS === */
h1, h2, h3, h4, h5 {
    text-align: center;
    width: 100%;
}

/* === ELEMENTOS CENTRADOS === */
.card,
.blur-shadow,
.table-responsive {
    max-width: 100%;
    margin: 0 auto;
}

.row.g-4,
.row.justify-content-center {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

.card-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* === FORMULARIOS === */
.alta_form,
.main_form {
    max-width: 400px;
    margin: 0 auto;
}

/* === MENSAJES === */
.message-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

/* === FOOTER === */
footer {
    width: 100%;
    text-align: center;
    padding: 20px;
}

/* ==========================================
   RESPONSIVE MÓVIL (max 768px)
   ========================================== */
@media (max-width: 768px) {
    /* OCULTAR HEADER COMPLETO EN MÓVIL */
    header,
    .header,
    .header-container {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Mostrar hamburguesa y logo móvil */
    #mobile-menu-toggle {
        display: flex !important;
    }

    #mobile-logo {
        display: block !important;
    }

    /* Ajustar padding del contenido principal */
    body {
        padding-top: 0 !important;
    }

    /* Para páginas con main/content */
    main,
    #main-content,
    .flex-fill {
        padding-top: 70px !important;
        margin-top: 0 !important;
    }

    .container.py-4 {
        padding-top: 70px !important;
    }

    /* Para basen.html (página index) - IMPORTANTE */
    body.main-layout {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        padding-top: 0 !important;
    }

    #testi {
        margin-top: 70px !important;
    }

    #contact {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
        margin-top: 0 !important;
        min-height: calc(100vh - 150px);
        display: flex;
        align-items: center;
    }

    #contact .container {
        padding-top: 0 !important;
        width: 100%;
    }

    #contact .row {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    #contact .col-md-6 {
        width: 100%;
        padding: 15px !important;
    }

    #contact figure {
        margin: 0 auto 30px !important;
        padding: 0 !important;
    }

    #contact figure img {
        max-width: 160px !important;
        height: auto;
        margin: 0 auto;
        display: block;
    }

    #contact .titlepage {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    #contact .titlepage h2 {
        font-size: 1.4rem !important;
        margin-bottom: 20px;
    }

    #contact .main_form {
        max-width: 280px !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    .contactus {
        width: 100% !important;
        max-width: 280px !important;
        margin: 10px auto !important;
        font-size: 14px !important;
    }

    .send_btn {
        width: 100% !important;
        max-width: 280px !important;
        margin: 15px auto 0 !important;
        display: block;
    }

    /* Mensajes de alerta en index */
    .message-area {
        margin-top: 20px !important;
        max-width: 280px;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .message-area .alert {
        font-size: 13px !important;
        padding: 10px !important;
        margin: 10px 0 !important;
    }

    /* Títulos */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    /* Tablas */
    .table-responsive {
        overflow-x: auto;
    }

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

    .table th,
    .table td {
        padding: 8px 5px;
    }

    .table .btn {
        padding: 5px 8px;
        font-size: 12px;
    }

    /* Formularios */
    .alta,
    .contactus,
    .form-control {
        width: 100% !important;
        margin: 8px 0;
    }

    .alta_form,
    .main_form {
        padding: 15px 10px;
        max-width: 300px;
    }

    /* Modales */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    /* Tarjetas */
    .card-group {
        flex-direction: column;
    }

    .col-md-4,
    .col-md-5,
    .col-md-6 {
        width: 100%;
        max-width: 500px;
        margin: 0 auto;
    }

    /* Búsqueda */
    .row.justify-content-center.mb-4 > div {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Mensajes */
    .message-fixed {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    /* Footer */
    footer p {
        font-size: 12px;
    }

    /* Index */
    #contact .row {
        flex-direction: column;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    #contact .col-md-6 {
        width: 100%;
        padding: 10px 15px !important;
    }

    #contact figure img {
        max-width: 180px;
        height: auto;
        margin: 20px auto 30px;
        display: block;
    }

    #contact .titlepage {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    #contact .d-flex.flex-column.align-items-center {
        padding-top: 0 !important;
    }

    /* Container */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Ocultar elementos innecesarios */
    .d-none.d-md-block,
    .col-md-1 {
        display: none !important;
    }
}

/* ==========================================
   RESPONSIVE MÓVIL PEQUEÑO (max 576px)
   ========================================== */
@media (max-width: 576px) {
    #mobile-nav {
        width: 260px;
    }

    .btn {
        font-size: 13px;
        padding: 8px 12px;
    }

    #prevBtn,
    #nextBtn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* ==========================================
   RESPONSIVE MÓVIL MUY PEQUEÑO (max 360px)
   ========================================== */
@media (max-width: 360px) {
    body {
        font-size: 12px;
    }

    h1 {
        font-size: 1.3rem !important;
    }

    #mobile-nav {
        width: 240px;
    }
}

/* ==========================================
   LANDSCAPE
   ========================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        position: relative;
    }

    #mobile-nav {
        padding-top: 60px;
    }
}

/* ==========================================
   UTILIDADES
   ========================================== */
.text-center {
    text-align: center !important;
}

.d-flex {
    display: flex !important;
}

.justify-content-center {
    justify-content: center !important;
}

.align-items-center {
    align-items: center !important;
}