/* ================================================
   ESTILOS BASE (MANTENIDOS)
================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #F5F7FA;
    color: #333;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: #333;
}

a:hover {
    text-decoration: none; 
    color: #2C3E50;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

header h1 {
    color: #2C3E50;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* ================================================
   BUSCADOR (ACTUALIZADO)
================================================ */

.search-container {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#province-filter, 
#search-input {
    padding: 15px;
    font-size: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    transition: all 0.3s;
}

#province-filter {
    min-width: 200px;
    cursor: pointer;
}

#search-input {
    flex: 1;
    min-width: 250px;
}

#search-input:focus, 
#province-filter:focus {
    outline: none;
    border-color: #888;
}

#search-button {
    background: #2C3E50;
    color: white;
    border: none;
    padding: 15px 25px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s;
}

#search-button:hover {
    opacity: 0.9;
}

/* ================================================
   OPCIONES DE BÚSQUEDA (NUEVO)
================================================ */

.search-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #2C3E50;
    font-weight: 500;
    user-select: none;
}

.option-label input[type="checkbox"] {
    display: none;
}

.option-label .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #2C3E50;
    border-radius: 4px;
    display: inline-block;
    position: relative;
    transition: all 0.3s;
}

.option-label input:checked + .checkmark {
    background-color: #2C3E50;
    border-color: #2C3E50;
}

.option-label input:checked + .checkmark::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.option-label .fa-store {
    color: #27ae60;
    font-size: 13px;
}

.option-label:hover .checkmark {
    border-color: #34495e;
}

/* ================================================
   CONTROLES E INFO
================================================ */

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #eee;
    padding-top: 15px;
    gap: 15px;
}

.search-info {
    text-align: center; 
    font-size: 14px;
    margin: 0;
    min-width: 200px;
}

#result-count {
    font-weight: bold;
    color: #2C3E50;
    display: block;
    margin-bottom: 2px;
}

#search-time {
    color: #6c757d;
}

/* ================================================
   BOTÓN DE AYUDA
================================================ */

#help-button {
    background: #2C3E50;
    color: white;
    border: none;
    padding: 8px 15px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.3s;
}

#help-button:hover {
    opacity: 0.9;
}

/* ================================================
   VISTA TABLA SIMPLE
================================================ */

.results-container {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.table-responsive {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #eee;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

#results-table th {
    background: #2C3E50;
    color: white;
    font-weight: 600;
    padding: 15px 10px;
    text-align: left;
    font-size: 0.9rem;
}

#results-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    font-size: 0.9rem;
    color: #444;
}

#results-table tr:nth-child(even) { 
    background-color: #F5F7FA; 
}

#results-table tr:hover { 
    background-color: #eef2f7; 
}

.ruc-cell {
    font-weight: bold;
    font-size: 1.2rem;
    color: #2C3E50;
}

.actividad-cell {
    max-width: 300px;
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

/* ================================================
   INDICADOR DE MATCH (NUEVO)
================================================ */

.match-indicator {
    display: inline-block;
    margin-left: 5px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: #e8f5e8;
    color: #27ae60;
    border: 1px solid #27ae60;
    vertical-align: middle;
}

.match-indicator.comercial {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.match-indicator.ruc {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

/* ================================================
   VISTA DETALLADA
================================================ */

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.detailed-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

.dc-row {
    display: flex;
    border-bottom: 1px solid #eee;
}

.dc-row:last-child {
    border-bottom: none;
}

.dc-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #eee;
}

.dc-cell:last-child {
    border-right: none;
}

.dc-header {
    background-color: #2C3E50;
    color: white;
    padding: 8px 10px;
    font-weight: 600;
    text-align: center;
    font-size: 12px;
    text-transform: uppercase;
}

.dc-value {
    padding: 12px 10px;
    text-align: center;
    color: #333;
    background: white;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    line-height: 1.4;
}

.dc-activity-container {
    padding: 15px;
    text-align: center;
    background: white;
}

.dc-activity-box {
    border: 1px solid #eee;
    padding: 15px;
    color: #333;
    text-align: justify;
    background: #F5F7FA;
    line-height: 1.5;
    font-size: 14px;
    border-radius: 4px;
}

.estado-activo {
    color: #27ae60;
    font-weight: bold;
}

.estado-inactivo {
    color: #e74c3c;
    font-weight: bold;
}

.detalles-row .dc-cell {
    flex: 1;
    min-width: 100px;
}

.detalles-row .dc-header {
    font-size: 11px;
    padding: 5px 5px;
}

.detalles-row .dc-value {
    font-size: 12px;
    padding: 8px 5px;
}

/* ================================================
   TABLA DE ESTABLECIMIENTOS
================================================ */

.establecimientos-section {
    padding: 15px;
    background: #f9f9f9;
    border-top: 2px solid #2C3E50;
}

.establecimientos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.establecimientos-table th {
    background-color: #34495e;
    color: white;
    font-weight: 600;
    padding: 10px 8px;
    text-align: left;
    border-right: 1px solid #2C3E50;
}

.establecimientos-table th:last-child {
    border-right: none;
}

.establecimientos-table td {
    padding: 8px 8px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.establecimientos-table tr:nth-child(even) {
    background-color: #f5f7fa;
}

.establecimientos-table tr:hover {
    background-color: #eef2f7;
}

.estado-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.estado-ABR {
    background-color: #d5f4e6;
    color: #27ae60;
    border: 1px solid #27ae60;
}

.estado-CER {
    background-color: #fadbd8;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

/* ================================================
   BOTONES DE ACCIÓN
================================================ */

.card-actions {
    padding: 15px;
    text-align: right;
    background: #F5F7FA;
    border-top: 1px solid #eee;
}

.copy-btn {
    cursor: pointer;
    padding: 8px 15px;
    background: #2C3E50;
    color: white;
    border: 1px solid #2C3E50;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.copy-btn:hover {
    background: #34495e;
    border-color: #34495e;
}

/* ================================================
   ESTADOS VACÍOS
================================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    display: none;
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 20px;
    color: #ddd;
}

/* ================================================
   FOOTER
================================================ */

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: #888;
    font-size: 14px;
}

/* ================================================
   MODAL DE AYUDA
================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    padding-top: 50px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%; 
    max-width: 600px;
    border-radius: 10px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}

.modal-content h2 {
    color: #2C3E50;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.modal-content h3 {
    color: #555;
    font-size: 1.1rem;
    margin-top: 15px;
    margin-bottom: 5px;
}

.modal-content hr {
    border: 0;
    height: 1px;
    background: #eee;
    margin: 15px 0;
}

.modal-content table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}

.modal-content th, .modal-content td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.modal-content th {
    background-color: #f2f2f2;
    font-weight: 600;
    color: #2C3E50;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

/* ================================================
   RESPONSIVE
================================================ */

@media (max-width: 768px) {
    .search-box { 
        flex-direction: column; 
    }
    
    #province-filter, #search-input, #search-button { 
        width: 100%; 
    }
    
    .controls-row { 
        flex-direction: column; 
        align-items: stretch;
        gap: 15px;
    }
    
    .search-options, .search-info, #help-button { 
        width: 100%; 
    }
    
    .option-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-info {
        order: 1;
        text-align: center;
    }
    
    #help-button {
        order: 2;
    }
    
    .search-options {
        order: 3;
    }
    
    /* VISTA DETALLADA RESPONSIVE */
    .dc-row { 
        flex-wrap: wrap; 
    }
    
    .dc-cell { 
        flex: 0 0 100%; 
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    
    .dc-header { 
        text-align: left; 
        padding: 8px; 
    }
    
    .dc-value { 
        text-align: left; 
        justify-content: flex-start; 
        padding: 8px; 
    }
    
    /* FILA DETALLES EN MÓVIL */
    .detalles-row .dc-cell {
        flex: 0 0 50%;
        border-right: 1px solid #eee;
    }
    
    .detalles-row .dc-cell:nth-child(even) {
        border-right: none;
    }
    
    /* TABLA DE ESTABLECIMIENTOS EN MÓVIL */
    .establecimientos-table {
        display: block;
        overflow-x: auto;
    }
    
    .establecimientos-table th,
    .establecimientos-table td {
        padding: 6px 4px;
        font-size: 12px;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .search-container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .detalles-row .dc-cell {
        flex: 0 0 100%;
        border-right: none;
    }
    
    #results-table th,
    #results-table td {
        padding: 8px 5px;
        font-size: 12px;
    }
}