/* ================================================
   Estilos del Frontend - DataTables + Bootstrap 5
   ================================================ */

/* ── Tabla personalizada (ctd-contacts-table) ─────────────────────────── */
.ctd-phone-directory {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ctd-contacts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.ctd-contacts-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: #ffffff;
    font-size: 13px;
    border: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.ctd-contacts-table thead th .ctd-sort-icon {
    font-size: 11px;
    margin-left: 5px;
    opacity: 0.7;
}

.ctd-contacts-table thead th.ctd-sorted .ctd-sort-icon {
    opacity: 1;
}

.ctd-contacts-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    vertical-align: middle;
}

.ctd-contacts-table tbody tr.ctd-row-even {
    background: #ffffff;
}

.ctd-contacts-table tbody tr.ctd-row-odd {
    background: #f4f4f4;
}

.ctd-contacts-table tbody tr:hover {
    background: #edf7f0;
}

.ctd-contacts-table a.ctd-phone-link {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
}

.ctd-contacts-table a.ctd-phone-link:hover {
    text-decoration: underline;
}

.ctd-contacts-table a.ctd-email-link {
    color: #0066cc;
    text-decoration: none;
}

.ctd-contacts-table .ctd-empty {
    color: #9ca3af;
}

/* ── Controles superiores ─────────────────────────────────────────────── */
.ctd-directory-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.ctd-controls-export {
    display: flex;
    gap: 8px;
}

.ctd-export-button {
    background: #1e7e34;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ctd-export-button:hover {
    background: #155d27;
}

.ctd-export-print {
    background: #4b5563;
}

.ctd-export-print:hover {
    background: #374151;
}

.ctd-controls-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.ctd-per-page-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}

.ctd-per-page-select {
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.ctd-search-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ctd-search-label {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
}

.ctd-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.ctd-search-input {
    padding: 7px 32px 7px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    min-width: 220px;
    outline: none;
    transition: border-color 0.15s;
}

.ctd-search-input:focus {
    border-color: #2d7a3f;
    box-shadow: 0 0 0 2px rgba(45, 122, 63, 0.12);
}

.ctd-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    display: none;
}

.ctd-search-clear:hover {
    color: #374151;
}

/* ── Tabla wrapper y paginación ──────────────────────────────────────── */
.ctd-table-wrap {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.ctd-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    flex-wrap: wrap;
    gap: 8px;
}

.ctd-pagination-info {
    font-size: 13px;
    color: #6b7280;
}

.ctd-pagination-numbers {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.ctd-page-btn {
    padding: 5px 11px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.ctd-page-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.ctd-page-btn.ctd-page-active {
    background: #2d7a3f;
    border-color: #2d7a3f;
    color: #fff;
    font-weight: 600;
}

.ctd-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctd-page-ellipsis {
    padding: 5px 4px;
    color: #9ca3af;
    font-size: 13px;
}

.ctd-no-results,
.ctd-description {
    font-size: 14px;
    color: #6b7280;
    padding: 20px 0;
}

.contactos-directory-wrapper {
    margin: 20px 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.contactos-directory-wrapper h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #fff;
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    padding: 20px;
    border: none;
    border-radius: 8px 8px 0 0;
    font-size: 24px;
}

.contactos-directory-wrapper p {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    padding: 0 20px;
}

/* Estilos DataTables */
.contactos-directory-table {
    width: 100% !important;
    border-collapse: collapse;
    background: #fff;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.contactos-directory-table thead {
    background-color: #4a90e2;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
}

.contactos-directory-table thead th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 700;
    color: #fff;
    border: none;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contactos-directory-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #e8e8e8;
    font-size: 14px;
}

.contactos-directory-table tbody tr {
    background-color: #fff;
    transition: background-color 0.2s ease;
}

.contactos-directory-table tbody tr:nth-child(odd) {
    background-color: #f5f7fa;
}

.contactos-directory-table tbody tr:hover {
    background-color: #e8f0f7;
}

.contactos-directory-table a {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
}

.contactos-directory-table a:hover {
    text-decoration: underline;
    color: #005a87;
}

/* DataTables Controls */
.dt-buttons {
    margin-bottom: 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.dt-buttons .dt-button {
    background-color: #0073aa;
    color: white;
    padding: 8px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.dt-buttons .dt-button:hover {
    background-color: #005a87;
}

/* Buscar */
.dt-search {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dt-search label {
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

.dataTables_filter input {
    margin-left: 0 !important;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 250px;
}

.dataTables_filter input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

/* Info y paginación */
.dt-info {
    color: #666;
    font-size: 13px;
    margin-top: 0;
    padding: 0;
}

.dt-paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 6px;
    padding: 6px 0;
}

.dt-paging-button {
    padding: 6px 10px !important;
    margin: 0 !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    background: #fff !important;
    cursor: pointer;
    text-decoration: none;
    color: #0073aa !important;
    font-size: 13px;
    transition: all 0.2s;
}

.dt-paging-button:hover:not(.disabled) {
    background: #f5f7fa !important;
    border-color: #0073aa !important;
    color: #005a87 !important;
}

.dt-paging-button.current {
    background-color: #0073aa !important;
    color: white !important;
    border-color: #0073aa !important;
    font-weight: 600;
}

.dt-paging-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Longitud */
.dataTables_length select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.dataTables_length select:focus {
    outline: none;
    border-color: #0073aa;
}

/* Responsive */
@media (max-width: 768px) {
    .contactos-directory-table {
        font-size: 12px;
    }

    .contactos-directory-table thead th,
    .contactos-directory-table tbody td {
        padding: 8px;
    }

    .dt-buttons {
        flex-direction: column;
    }

    .dt-buttons .dt-button {
        padding: 6px 10px;
        font-size: 12px;
        width: 100%;
    }

    .dataTables_filter input {
        width: 100% !important;
    }

    .dt-paging {
        flex-wrap: wrap;
    }

    .dt-paging-button {
        padding: 4px 8px !important;
        font-size: 12px !important;
    }

    .dt-info {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .contactos-directory-wrapper h2 {
        font-size: 18px;
        padding: 15px;
    }

    .contactos-directory-table thead th {
        padding: 10px 6px;
        font-size: 11px;
    }

    .contactos-directory-table tbody td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .dt-search {
        flex-direction: column;
        align-items: flex-start;
    }

    .dt-search label {
        margin-bottom: 5px;
    }

    .dataTables_filter input {
        width: 100% !important;
    }
}

/* Contenedor DataTables */
.dt-container {
    background: #fff;
    border-radius: 0 0 8px 8px;
}

.dt-container .row {
    margin-left: 0;
    margin-right: 0;
}

.dt-container .col-sm-6,
.dt-container .col-sm-5,
.dt-container .col-sm-7,
.dt-container .col-sm-12 {
    padding-left: 0;
    padding-right: 0;
}