/* ============================================
   NAVE MUNICIPAL — Estilos Mobile First
   ============================================ */

/* ---- NAVEGACIÓN RÁPIDA NAVE ---- */
.nave-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 14px;
    padding: 6px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nave-nav a {
    flex-shrink: 0;
    padding: 8px 14px;
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.nave-nav a.active,
.nave-nav a:hover {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

/* ---- CONTENEDOR PRINCIPAL ---- */
.nave-registro-container,
.nave-condiciones-page {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
    padding: 4px 2px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

/* Forzar que Divi no limite el ancho */
.et_pb_code .nave-registro-container,
.et_pb_code .nave-condiciones-page,
.et_pb_text .nave-registro-container,
.et_pb_text .nave-condiciones-page {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.nave-registro-container h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
    color: #1e293b;
}

.nave-subtitulo {
    color: #64748b;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* ---- MENSAJES ---- */
.nave-msg {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 0.9rem;
}
.nave-msg-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.nave-msg-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ---- AVISO ---- */
.nave-aviso {
    padding: 16px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}
.nave-aviso a {
    color: #92400e;
    font-weight: 600;
}

/* ---- FORMULARIO ---- */
.nave-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.nave-form-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 8px;
    margin-bottom: 10px;
}

.nave-form-section h3 {
    font-size: 1rem;
    margin: 0 0 12px 0;
    color: #334155;
}

/* Mobile: una columna siempre */
.nave-form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.nave-form-group {
    margin-bottom: 12px;
}

.nave-form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 4px;
}

.nave-form-group input[type="text"],
.nave-form-group input[type="email"],
.nave-form-group input[type="tel"],
.nave-form-group input[type="date"],
.nave-form-group input[type="time"],
.nave-form-group input[type="number"],
.nave-form-group select,
.nave-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 16px; /* Evita zoom iOS */
    transition: border-color 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.nave-form-group input:focus,
.nave-form-group select:focus,
.nave-form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.nave-form-group small {
    display: block;
    margin-top: 3px;
    color: #94a3b8;
    font-size: 0.78rem;
}

.nave-form-group input[type="file"] {
    padding: 10px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    font-size: 14px;
}

/* ---- CHECKBOX ---- */
.nave-checkbox-label {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-weight: 500 !important;
    line-height: 1.4;
}

.nave-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.nave-checkbox-important {
    background: #fffbeb;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #fbbf24;
}

/* ---- FRANJAS ---- */
.nave-franjas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.nave-franja-option {
    cursor: pointer;
}

.nave-franja-option input[type="checkbox"] {
    display: none;
}

.nave-franja-card {
    display: block;
    padding: 10px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s;
}

.nave-franja-card strong {
    display: block;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.nave-franja-card small {
    color: #64748b;
    font-size: 0.78rem;
}

.nave-franja-option input:checked + .nave-franja-card {
    border-color: #6366f1;
    background: #eef2ff;
}

/* ---- MODAL CONDICIONES ---- */
.nave-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.nave-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: naveModalIn 0.25s ease;
}

@keyframes naveModalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.nave-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.nave-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #1e293b;
}

.nave-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.nave-modal-close:hover {
    color: #ef4444;
}

.nave-modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #475569;
    white-space: pre-wrap;
}

.nave-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: #f8fafc;
    border-radius: 0 0 14px 14px;
}

.nave-modal-footer .nave-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- CONDICIONES BOX (legacy/fallback) ---- */
.nave-condiciones-box {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nave-condiciones-texto {
    padding: 12px;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #475569;
    white-space: pre-wrap;
}

/* ---- INFO BOX ---- */
.nave-form-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
}

.nave-form-info p {
    margin: 4px 0;
    font-size: 0.85rem;
    color: #1e40af;
}

/* ---- BOTÓN ---- */
.nave-btn {
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
}

.nave-btn-primary {
    background: #6366f1;
    color: #fff;
}

.nave-btn-primary:hover {
    background: #4f46e5;
}

/* ---- ESTADO REGISTRO ---- */
.nave-estado-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.nave-estado-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.nave-estado-card strong {
    display: block;
    font-size: 1rem;
}

.nave-estado-card p {
    margin: 3px 0 0;
    color: #64748b;
    font-size: 0.88rem;
}

.nave-estado-pendiente { background: #fef3c7; border: 1px solid #fbbf24; }
.nave-estado-aprobado { background: #d1fae5; border: 1px solid #34d399; }
.nave-estado-rechazado { background: #fee2e2; border: 1px solid #f87171; }
.nave-estado-suspendido { background: #ffedd5; border: 1px solid #fb923c; }

/* ---- DATOS RESUMEN ---- */
.nave-datos-resumen {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
}

.nave-dato {
    padding: 6px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.nave-dato:last-child {
    border-bottom: none;
}

.nave-dato span {
    font-weight: 600;
    color: #475569;
    display: block;
    font-size: 0.8rem;
    margin-bottom: 1px;
}

/* ---- CÓDIGO NUKI ---- */
.nave-codigo-nuki {
    background: #ecfdf5;
    border: 2px solid #34d399;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin-bottom: 14px;
}

.nave-codigo-nuki h3 {
    margin: 0 0 8px;
    color: #065f46;
    font-size: 1rem;
}

.nave-codigo-display {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: #059669;
    letter-spacing: 6px;
    padding: 8px;
}

.nave-codigo-info {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 6px;
}

/* ---- RECHAZO ---- */
.nave-motivo-rechazo {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
}

.nave-motivo-rechazo strong {
    color: #991b1b;
}

/* ---- CONDICIONES PENDIENTES ---- */
.nave-condiciones-pendientes {
    background: #fffbeb;
    border: 2px solid #f59e0b;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
}

.nave-condiciones-pendientes h3 {
    margin: 0 0 8px;
    color: #92400e;
    font-size: 1rem;
}

/* ---- PRECIO ---- */
.nave-info-precio {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 10px;
}

/* ---- CONDICIONES PAGE ---- */

.nave-version-info {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 14px;
}

.nave-condiciones-contenido {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 0.88rem;
}

/* ============================================
   PANEL ADMIN NAVE — Mobile First (scroll horizontal)
   ============================================ */

/* Sub-tabs en móvil scroll horizontal */
#tab-nave-municipal > div:first-child {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 4px;
}

#tab-nave-municipal .nave-subtab-btn {
    flex-shrink: 0;
    font-size: 0.82rem !important;
    padding: 8px 14px !important;
}

/* Grid resumen rápido en móvil 2 columnas */
#tab-nave-municipal > div:nth-child(2) {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
}

/* Cards pro en móvil */
#tab-nave-municipal .card-pro {
    padding: 14px 10px !important;
}

/* === EDITOR TinyMCE de condiciones: ocupa todo el ancho del contenedor === */
#nave-sub-condiciones .wp-editor-wrap,
#nave-sub-condiciones .wp-editor-container,
#nave-sub-condiciones .wp-editor-tools {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
#nave-sub-condiciones textarea#nave-cond-contenido {
    width: 100% !important;
    max-width: 100% !important;
}
#nave-sub-condiciones .mce-tinymce,
#nave-sub-condiciones .mce-container,
#nave-sub-condiciones .mce-toolbar,
#nave-sub-condiciones .mce-stack-layout,
#nave-sub-condiciones .mce-edit-area,
#nave-sub-condiciones iframe.wp-editor-area {
    width: 100% !important;
    max-width: 100% !important;
}
#nave-sub-condiciones .mce-toolbar-grp {
    background: #f8fafc !important;
}
#nave-sub-condiciones .mce-edit-area iframe {
    width: 100% !important;
    min-height: 350px !important;
}

/* === MÓVIL: tabla con SCROLL HORIZONTAL, columnas ocultas y anchos fijos === */
@media (max-width: 640px) {
    /* Scroll horizontal en el contenedor */
    #tab-nave-municipal .card-pro > div[style*="overflow-x"] {
        margin: 0 -10px !important;
        padding: 0 !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* La tabla mantiene un ancho mínimo que cabe Nombre+Empadronado+Estado+Nuki+Acciones */
    #tab-nave-municipal table {
        min-width: 600px !important;
        width: 100% !important;
        font-size: 0.82rem !important;
        border-collapse: collapse !important;
    }

    /* Ocultar columnas secundarias.
       Mostramos: Nombre(1) · Empadronado(3) · Estado(7) · Nuki(8) · Acciones(11)
       (las thead son Nombre,DNI,Empadronado,Uso,Franjas,Gracia,Estado,Nuki,Fecha,Acciones) */
    #tab-nave-municipal table th:nth-child(2),  /* DNI */
    #tab-nave-municipal table td[data-label="DNI"],
    #tab-nave-municipal table th:nth-child(4),  /* Uso */
    #tab-nave-municipal table td[data-label="Uso"],
    #tab-nave-municipal table th:nth-child(5),  /* Franjas */
    #tab-nave-municipal table td[data-label="Franjas"],
    #tab-nave-municipal table th:nth-child(6),  /* Gracia */
    #tab-nave-municipal table td[data-label="Gracia"],
    #tab-nave-municipal table th:nth-child(9),  /* Fecha */
    #tab-nave-municipal table td[data-label="Fecha"] {
        display: none !important;
    }

    /* Estilo general de celdas */
    #tab-nave-municipal table th,
    #tab-nave-municipal table td {
        padding: 10px 8px !important;
        font-size: 0.82rem !important;
        white-space: nowrap !important;
        vertical-align: middle !important;
    }

    #tab-nave-municipal table th {
        font-size: 0.72rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.03em !important;
        background: #f1f5f9 !important;
    }

    /* Nombre: ancho razonable y permite wrap */
    #tab-nave-municipal table td[data-label="Nombre"],
    #tab-nave-municipal table td[data-label="Solicitante"] {
        min-width: 170px !important;
        max-width: 220px !important;
        white-space: normal !important;
        font-weight: 600 !important;
        color: #1e293b !important;
        line-height: 1.3 !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    /* Empadronado: solo el icono, columna estrecha y centrada */
    #tab-nave-municipal table th:nth-child(3),
    #tab-nave-municipal table td[data-label="Empadronado"] {
        width: 50px !important;
        min-width: 50px !important;
        text-align: center !important;
        padding: 8px 4px !important;
    }

    /* Estado: badge sin wrap */
    #tab-nave-municipal table td[data-label="Estado"] {
        min-width: 110px !important;
    }

    /* Nuki: código + estado */
    #tab-nave-municipal table td[data-label="Nuki"] {
        min-width: 110px !important;
    }

    /* Acciones: botones en fila, sin wrap (la columna se hace ancha si hace falta) */
    #tab-nave-municipal table td[data-label="Acciones"] {
        min-width: 220px !important;
        white-space: nowrap !important;
    }
    #tab-nave-municipal table td[data-label="Acciones"] > div {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
    }
    #tab-nave-municipal table td[data-label="Acciones"] button {
        min-height: 32px !important;
        padding: 5px 8px !important;
        font-size: 0.72rem !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    #tab-nave-municipal table td[data-label="Acciones"] button[title]:not([title=""]) {
        min-width: 32px !important;
        padding: 5px !important;
        font-size: 0.88rem !important;
    }

    /* Indicador visual de que hay scroll horizontal: gradiente sutil al borde derecho */
    #tab-nave-municipal .card-pro > div[style*="overflow-x"] {
        position: relative;
    }
    #tab-nave-municipal .card-pro > div[style*="overflow-x"]::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 24px;
        background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
        pointer-events: none;
        opacity: 0.7;
    }
}

/* === DESKTOP/TABLET: scroll horizontal de tabla normal === */
@media (min-width: 641px) {
    #tab-nave-municipal table {
        font-size: 0.88rem;
    }
    #tab-nave-municipal table td {
        white-space: nowrap;
    }
    #tab-nave-municipal table td[data-label="Nombre"],
    #tab-nave-municipal table td[data-label="Solicitante"] {
        white-space: normal;
        min-width: 160px;
    }
    #tab-nave-municipal table td[data-label="Acciones"] {
        white-space: nowrap;
        min-width: 200px;
    }
    #tab-nave-municipal table td button {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* Filtros de usuarios scroll horizontal */
#nave-sub-usuarios .card-pro > div:nth-child(2) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding-bottom: 4px;
}

/* .button-nave-filter definida en admin-dashboard.css */

/* Tarjetas de familias con botones en fila */
#nave-sub-familias .card-pro > div[style*="background:#fff"] {
    padding: 12px !important;
}

#nave-sub-familias .card-pro > div[style*="background:#fff"] > div:first-child > div:last-child {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    width: 100%;
    padding-bottom: 4px;
}

/* ============================================
   DESKTOP (>= 640px)
   ============================================ */
@media (min-width: 640px) {
    .nave-registro-container,
    .nave-condiciones-page {
        max-width: 720px !important;
        padding: 20px;
    }

    .nave-form-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .nave-registro-container h2 {
        font-size: 1.6rem;
    }

    .nave-form-section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .nave-form-row {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .nave-form-section h3 {
        font-size: 1.1rem;
    }

    .nave-btn {
        width: auto;
    }

    .nave-dato span {
        display: inline-block;
        min-width: 140px;
        font-size: 0.9rem;
    }

    .nave-codigo-display {
        font-size: 2.5rem;
        letter-spacing: 8px;
    }

    .nave-condiciones-box {
        max-height: 300px;
    }

    .nave-estado-card {
        padding: 20px;
    }

    .nave-nav a {
        padding: 10px 18px;
        font-size: 0.88rem;
    }

    /* Panel admin desktop */
    #tab-nave-municipal table {
        min-width: auto;
        font-size: 0.9rem;
    }

    #tab-nave-municipal table td {
        white-space: normal;
    }

    #tab-nave-municipal > div:nth-child(2) {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    }
}
