/* ==========================================================
   MATA - GESTIÓN DE INCIDENCIAS
   ========================================================== */

.mata-inc-heading{max-width:720px;margin-bottom:28px}
.mata-inc-kicker{display:block;margin-bottom:7px;color:#637487;font-size:11px;font-weight:800;letter-spacing:.1em;text-transform:uppercase}
.mata-inc-heading h2{margin:0 0 10px;color:var(--mata-title,#172c44);font-size:28px;line-height:1.2}
.mata-inc-heading p{margin:0;color:#5d6b79;line-height:1.65}


/* Pantalla inicial */
.mata-inc-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}
.mata-inc-option{display:flex;align-items:center;min-height:132px;padding:22px;background:#fff;border:1px solid #dfe5eb;border-radius:13px;color:inherit!important;text-decoration:none!important;transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease}
.mata-inc-option:hover{transform:translateY(-3px);border-color:var(--mata-blue,#315f8c);box-shadow:0 12px 28px rgba(23,44,68,.08)}
.mata-inc-option-content{display:flex;flex-direction:column;gap:5px;width:100%}
.mata-inc-option strong{color:var(--mata-title,#172c44);font-size:17px}
.mata-inc-option small{color:#647281;line-height:1.5}
.mata-inc-history-link{margin-top:20px}

/* Formulario */
.mata-inc-back{display:inline-flex;gap:8px;align-items:center;margin-bottom:24px;color:var(--mata-blue,#315f8c)!important;font-weight:700;text-decoration:none!important}
.mata-inc-search-box,.mata-inc-selected,.mata-inc-field{margin-bottom:24px}
.mata-inc-search-box label,.mata-inc-field label{display:block;margin-bottom:8px;font-weight:700;color:#22384f}
.mata-inc-search-row{display:flex;gap:10px}
.mata-inc-search-row input{flex:1;min-width:0}
.mata-inc-search-btn,.mata-inc-add,.mata-inc-submit{display:inline-flex!important;align-items:center;justify-content:center}
.mata-inc-search-results{margin-top:18px}

/* Tablas */
.mata-inc-table-scroll{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid #d8e0e8;border-radius:10px;background:#fff}
.mata-inc-table{width:100%;min-width:920px;border-collapse:separate;border-spacing:0;background:#fff;margin:0!important}
.mata-inc-table th,.mata-inc-table td{padding:13px 12px;border:0;border-bottom:1px solid #e4e9ee;text-align:left;vertical-align:middle}
.mata-inc-table thead th{background:#173653!important;color:#fff!important;font-size:12px!important;font-weight:800!important;line-height:1.3!important;letter-spacing:.025em;text-transform:none!important;white-space:normal!important;overflow:visible!important;text-overflow:clip!important;word-break:normal!important;hyphens:auto}
.mata-inc-table thead th:first-child{border-top-left-radius:9px}
.mata-inc-table thead th:last-child{border-top-right-radius:9px}
.mata-inc-table tbody td{color:#2f4052;font-size:13px;white-space:nowrap}
.mata-inc-table tbody tr:last-child td{border-bottom:0}
.mata-inc-table tbody tr:hover td{background:#f8fafc}
.mata-inc-table input[type=number]{width:112px;min-width:96px}
.mata-inc-table th:nth-child(6),.mata-inc-table th:nth-child(7){min-width:138px}
.mata-inc-table th:last-child,.mata-inc-table td:last-child{text-align:center;width:72px}
.mata-inc-remove{display:inline-flex;align-items:center;justify-content:center;min-width:74px;height:34px;padding:0 12px;border:0;border-radius:8px;background:#fff1f0;color:#b42318;font-size:12px;font-weight:700;cursor:pointer;transition:background .18s ease,color .18s ease}
.mata-inc-remove:hover{background:#b42318;color:#fff}
.mata-inc-empty td{text-align:center!important;color:#718096;padding:24px!important;white-space:normal!important}

/* Campos inferiores */
.mata-inc-fields-grid{display:grid;grid-template-columns:1fr 1fr;gap:22px}
.mata-inc-field select,.mata-inc-field textarea,.mata-inc-field input[type=file]{width:100%}
.mata-inc-field input[type=file]{padding:12px;border:1px solid #d8e0e8;border-radius:8px;background:#fff}
.mata-inc-field small{display:block;margin-top:7px;color:#647281;line-height:1.45}
.mata-inc-previews{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.mata-inc-previews img{width:82px;height:82px;object-fit:cover;border-radius:8px;border:1px solid #dfe5eb}
.mata-inc-form-message{margin:12px 0}
.mata-inc-form-message.ok{color:#157347}
.mata-inc-form-message.error,.mata-inc-error{color:#b42318}
.mata-inc-note{color:#647281}
.mata-inc-submit{min-width:180px}

@media(max-width:767px){
 .mata-inc-options,.mata-inc-fields-grid{grid-template-columns:1fr}
 .mata-inc-option{min-height:112px;padding:18px}
 .mata-inc-search-row{flex-direction:column}
 .mata-inc-search-btn{width:100%}
 .mata-inc-table{min-width:860px}
 .mata-inc-heading h2{font-size:24px}
}

@media(prefers-reduced-motion:reduce){
 .mata-inc-option,.mata-inc-remove{transition:none!important}
}


/* ==========================================================
   CORRECCIONES DE COMPATIBILIDAD CON EL TEMA
   ========================================================== */

/* Cabeceras siempre legibles, aunque el tema fuerce colores en tablas. */
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead,
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead tr,
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead th {
    background-color: #173653 !important;
}

body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead th,
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead th *,
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead th a,
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead th span {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: none !important;
}

body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table thead th {
    min-height: 48px;
    padding: 14px 13px !important;
    vertical-align: middle !important;
    white-space: normal !important;
    overflow: visible !important;
    line-height: 1.35 !important;
}

body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(1) { min-width: 105px; }
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(2) { min-width: 100px; }
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(3) { min-width: 88px; }
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(4) { min-width: 92px; }
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(5) { min-width: 105px; }
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(6),
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:nth-child(7) { min-width: 155px; }
body.woocommerce-account .woocommerce-MyAccount-content .mata-inc-table th:last-child { min-width: 72px; }

/* ==========================================================
   RESULTADOS DE BÚSQUEDA EN TARJETAS
   ========================================================== */

.mata-inc-result-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.mata-inc-result-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "main button"
        "data button";
    align-items: center;
    gap: 11px 14px;

    min-width: 0;
    padding: 15px 16px;

    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 11px;

    box-shadow: 0 4px 14px rgba(23, 54, 83, 0.045);

    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.mata-inc-result-card:hover {
    transform: translateY(-2px);
    border-color: #b8c7d5;
    box-shadow: 0 9px 22px rgba(23, 54, 83, 0.075);
}

.mata-inc-result-card.is-added {
    border-color: #9fc4ad;
    background: #fbfefc;
}

.mata-inc-result-main {
    grid-area: main;
    min-width: 0;
}

.mata-inc-result-code {
    margin-bottom: 5px;
    color: #172c44;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.mata-inc-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 13px;
    color: #617080;
    font-size: 12px;
    line-height: 1.4;
}

.mata-inc-result-meta strong {
    color: #405164;
    font-weight: 700;
}

.mata-inc-result-data {
    grid-area: data;
    display: flex;
    flex-wrap: wrap;
    gap: 9px 18px;
    min-width: 0;
}

.mata-inc-result-data > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mata-inc-result-data small {
    color: #7a8794;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: 0.035em;
}

.mata-inc-result-data strong {
    color: #2f4052;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
}

.mata-inc-add {
    grid-area: button;
    align-self: center;

    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    min-width: 106px;
    min-height: 38px;
    margin: 0 !important;
    padding: 8px 13px !important;

    background: #173653 !important;
    border: 1px solid #173653 !important;
    border-radius: 8px !important;

    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    text-align: center;
    white-space: nowrap;

    box-shadow: none !important;
    cursor: pointer;
}

.mata-inc-add:hover,
.mata-inc-add:focus {
    background: #0f2941 !important;
    border-color: #0f2941 !important;
    color: #ffffff !important;
}

.mata-inc-add:disabled {
    background: #e8f1eb !important;
    border-color: #bfd4c5 !important;
    color: #36704b !important;
    opacity: 1 !important;
    cursor: default;
}

/* ==========================================================
   TABLA DE ARTÍCULOS AÑADIDOS
   ========================================================== */

.mata-inc-selected .mata-inc-table-scroll {
    position: relative;
}

.mata-inc-selected .mata-inc-table {
    min-width: 860px;
    table-layout: fixed;
}

.mata-inc-selected .mata-inc-table th,
.mata-inc-selected .mata-inc-table td {
    padding: 11px 9px !important;
}

.mata-inc-selected .mata-inc-table th:nth-child(1),
.mata-inc-selected .mata-inc-table td:nth-child(1) { width: 108px; }
.mata-inc-selected .mata-inc-table th:nth-child(2),
.mata-inc-selected .mata-inc-table td:nth-child(2) { width: 94px; }
.mata-inc-selected .mata-inc-table th:nth-child(3),
.mata-inc-selected .mata-inc-table td:nth-child(3) { width: 74px; }
.mata-inc-selected .mata-inc-table th:nth-child(4),
.mata-inc-selected .mata-inc-table td:nth-child(4) { width: 92px; }
.mata-inc-selected .mata-inc-table th:nth-child(5),
.mata-inc-selected .mata-inc-table td:nth-child(5) { width: 104px; }
.mata-inc-selected .mata-inc-table th:nth-child(6),
.mata-inc-selected .mata-inc-table td:nth-child(6) { width: 122px; }
.mata-inc-selected .mata-inc-table th:nth-child(7),
.mata-inc-selected .mata-inc-table td:nth-child(7) { width: 126px; }
.mata-inc-selected .mata-inc-table th:nth-child(8),
.mata-inc-selected .mata-inc-table td:nth-child(8) { width: 76px; }

.mata-inc-selected .mata-inc-table input[type="number"] {
    width: 100% !important;
    min-width: 0 !important;
    height: 38px;
    padding: 6px 7px !important;
}

.mata-inc-selected .mata-inc-actions-cell,
.mata-inc-selected .mata-inc-table th:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #ffffff !important;
    box-shadow: -7px 0 10px -10px rgba(23, 54, 83, 0.55);
}

.mata-inc-selected .mata-inc-table thead th:last-child {
    z-index: 4;
    background: #173653 !important;
}

.mata-inc-selected .mata-inc-remove {
    min-width: 58px;
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .mata-inc-result-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575px) {
    .mata-inc-result-card {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "data"
            "button";
        padding: 14px;
    }

    .mata-inc-add {
        width: 100%;
    }

    .mata-inc-result-data {
        gap: 8px 14px;
    }
}


/* ==========================================================
   HISTORIAL: COLUMNAS MÁS COMPACTAS
   ========================================================== */

.mata-inc-history-table {
    min-width: 0 !important;
    table-layout: fixed;
}

.mata-inc-history-table th,
.mata-inc-history-table td {
    padding: 11px 9px !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
}

.mata-inc-history-table th:nth-child(1),
.mata-inc-history-table td:nth-child(1) { width: 25%; }
.mata-inc-history-table th:nth-child(2),
.mata-inc-history-table td:nth-child(2) { width: 25%; }
.mata-inc-history-table th:nth-child(3),
.mata-inc-history-table td:nth-child(3) { width: 29%; }
.mata-inc-history-table th:nth-child(4),
.mata-inc-history-table td:nth-child(4) { width: 21%; }

/* Cantidades en formato español, sin spinner de centésimas. */
.mata-inc-selected .mata-inc-table .mata-qty-input {
    width: 100% !important;
    min-width: 0 !important;
    height: 38px;
    padding: 6px 7px !important;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 575px) {
    .mata-inc-history-table {
        min-width: 560px !important;
    }
}
