/* Core UI: tabs, cards, tablas base, sub-tabs, integraciones */

/* Tiles para Modo Judicial/Extrajudicial */
.form-check-tile {
    position: relative;
}

.tile-label {
    width: 100%;
    cursor: pointer;
    margin: 0;
}

.tile-option {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 80px;
    justify-content: center;
}

.tile-option i {
    font-size: 1.5rem;
    color: #6c757d;
}

.tile-option span {
    font-weight: 500;
    color: #495057;
}

.form-check-input:checked ~ .tile-label .tile-option {
    border-color: #007bff;
    background: #e7f3ff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-check-input:checked ~ .tile-label .tile-option i,
.form-check-input:checked ~ .tile-label .tile-option span {
    color: #007bff;
}

.form-check-tile .form-check-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Columna Estado en Historial de Consultas: asegurar que el switch sea visible */
#consultations-table th:nth-child(8),
#consultations-table td:nth-child(8) {
    min-width: 90px;
    white-space: nowrap;
}

/* Responsables y co-responsables tags */
.responsable-tag,
.co-responsable-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #e3f2fd;
    color: #1976d2;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.responsable-tag .btn-close,
.co-responsable-tag .btn-close {
    font-size: 0.7rem;
    padding: 0.2rem;
}

/* Cabecera + pestañas: fijas al viewport (sticky falla si algún ancestro usa overflow/backdrop distinto de visible) */
#dashboard-section {
    /* Cabecera + una fila de solapas (nowrap en PC) */
    --dashboard-top-offset: 8.25rem;
}
@media (max-width: 768px) {
    #dashboard-section {
        --dashboard-top-offset: 11rem;
    }
}

#dashboard-section .dashboard-sticky-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    box-sizing: border-box;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Sombra de la cabecera “invadía” la fila de solapas y tapaba el texto (PC). Sin sombra + borde fino. */
#dashboard-section .dashboard-header {
    flex: 0 0 auto;
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

/* Tabs */
.tabs-nav {
    background: linear-gradient(120deg, rgba(10, 16, 32, 0.9), rgba(16, 28, 54, 0.9));
    border-bottom: 1px solid rgba(0, 173, 255, 0.35);
    padding: 0.5rem 2rem;
    display: flex;
    gap: 0.75rem;
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: auto;
    flex-wrap: wrap;
    justify-content: flex-start;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(12px);
}

/*
 * PC: barra fija + overflow-x:hidden + flex-wrap recortaba la 2.ª fila de solapas (texto invisible).
 * Una sola fila con scroll horizontal si hace falta; sin backdrop-filter (evita glitches con fixed).
 */
#dashboard-section .tabs-nav {
    flex: 0 0 auto;
    position: relative;
    margin-top: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    align-items: center;
    min-height: 3.25rem;
    box-shadow: none;
    /* Fondo opaco: el gradiente con alpha dejaba transparente y se veía la cabecera “encima” del texto */
    background: linear-gradient(120deg, rgb(10, 16, 32), rgb(16, 28, 54));
}

#dashboard-section .tabs-nav::-webkit-scrollbar {
    height: 5px;
}

#dashboard-section .tabs-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 224, 255, 0.35);
    border-radius: 4px;
}

#dashboard-section .tabs-nav::before {
    display: none;
}

#dashboard-section .tab-btn {
    overflow: visible;
    flex: 0 0 auto;
}

.tabs-nav::-webkit-scrollbar {
    display: none;
}

.tabs-nav::before {
    content: "";
    position: absolute;
    inset: -60% -30%;
    background: radial-gradient(circle at 20% 20%, rgba(0, 221, 255, 0.12), transparent 45%),
                radial-gradient(circle at 80% 20%, rgba(0, 119, 255, 0.1), transparent 40%);
    filter: blur(18px);
    z-index: 0;
    animation: none;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 173, 255, 0.25);
    padding: 0.75rem 1.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #d8e9ff;
    letter-spacing: 0.4px;
    border-radius: 10px;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    box-shadow: none;
    transform: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    overflow: hidden;
    z-index: 1;
}

.tab-btn::before {
    content: "";
    position: absolute;
    inset: 2px;
    background: linear-gradient(120deg, rgba(0, 173, 255, 0.08), rgba(0, 255, 214, 0.05));
    border-radius: 8px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab-btn::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #00e0ff, #7cf3ff, #00ffd5);
    box-shadow: 0 0 12px rgba(0, 224, 255, 0.7);
    transform: translateX(-50%);
    transition: width 0.2s ease, opacity 0.2s ease;
}

.tab-btn span {
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    display: inline-block;
}

.tab-btn:focus,
.tab-btn:active {
    outline: none;
    box-shadow: none;
}

.tab-btn:hover {
    color: #00e0ff;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(0, 224, 255, 0.65);
    transform: none !important;
    box-shadow: none;
}

.tab-btn.active {
    color: #00ffd5;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(0, 224, 255, 0.15), rgba(0, 173, 255, 0.08));
    border-color: rgba(0, 224, 255, 0.85);
    box-shadow: none;
    animation: none;
    transform: none !important;
}

.tab-btn:hover::before,
.tab-btn.active::before {
    opacity: 1;
}

.tab-btn:hover::after {
    width: 0;
}

.tab-btn.active::after {
    width: 90%;
    height: 2px;
    bottom: 4px;
    box-shadow: none;
}

/* Main Content */
.main-content {
    padding: 1.5rem;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

/* Espacio bajo la barra fija (cabecera + solapas) para que el contenido no quede tapado */
#dashboard-section > .main-content {
    padding-top: calc(var(--dashboard-top-offset, 8.25rem) + 1.5rem);
}

.main-tab-content {
    display: none !important;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.main-tab-content.active {
    display: block !important;
    opacity: 1;
    animation: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tabPulse {
    0%, 100% { box-shadow: 0 10px 30px rgba(0, 224, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
    50% { box-shadow: 0 15px 40px rgba(0, 255, 213, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
}

@keyframes nebulaShift {
    0% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(-12px, -10px, 0); }
    100% { transform: translate3d(10px, 12px, 0); }
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    width: 100%;
    padding-left: 1rem;
}

.content-header > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
}

#btn-nuevo-contacto { margin-left: 0; }
#tab-agenda { padding-left: 2rem; }
#tab-agenda .sub-tabs-nav,
#tab-agenda .filters-card,
#tab-agenda .sub-tab-content { margin-left: 0; }
#btn-agendar { margin-right: 10% !important; }

.filters-card, .table-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#tab-agenda .filters-card { padding: 2rem; }
#tab-agenda .filters-card .form-label {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
#tab-agenda .filters-card .form-select {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    height: auto;
}

.table { margin-bottom: 0; }
.table thead th {
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 25px;
}
.table thead th.sortable:hover { background-color: #f8f9fa; }
.table thead th.sortable i {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85em;
    color: #6c757d;
    opacity: 0.6;
}
.table thead th.sortable:hover i { opacity: 1; color: #495057; }
.table thead th.sortable.sorted-asc i,
.table thead th.sortable.sorted-desc i {
    opacity: 1;
    color: #0d6efd;
}

.table tbody td:nth-child(2),
.table tbody td:nth-child(6) { white-space: nowrap; }
.table tbody td:nth-child(2) { min-width: 140px; }
.table tbody td:nth-child(6) { min-width: 120px; }
.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: #f8f9fa; }

.badge-consulta,
.badge-caso,
.badge-cliente-amplia,
.badge-otro {
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}
.badge-consulta { background: #d1f7d6; color: #198754; }
.badge-caso { background: #cff4fc; color: #036781; }
.badge-cliente-amplia { background: #fff3cd; color: #856404; }
.badge-otro { background: #e2d5f1; color: #5a3d7a; }

.btn { border-radius: 6px; font-weight: 500; padding: 0.45rem 0.9rem; font-size: 0.875rem; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.card-title { font-size: 1rem; }
h5 { font-size: 1rem; }
h4 { font-size: 1.1rem; }
h3 { font-size: 1.25rem; }
.btn-success { background: #28a745; border-color: #28a745; }
.btn-outline-primary { border-color: #1e3a5f; color: #1e3a5f; }
.btn-outline-primary:hover { background: #1e3a5f; border-color: #1e3a5f; }

.pagination .page-link { color: #1e3a5f; border-color: #dee2e6; }
.pagination .page-item.active .page-link {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #ffffff !important;
}

.sub-tabs-nav {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    padding: 0.5rem 2rem;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px 8px 0 0;
}
.sub-tab-btn {
    background: none;
    border: none;
    padding: 0.85rem 1.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: #6c757d;
    border-bottom: 3px solid transparent;
    transition: color 0.15s ease, background-color 0.15s ease, border-bottom-color 0.15s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    transform: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    font-weight: 500;
}
.sub-tab-btn span {
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    display: inline-block;
}
.sub-tab-btn[aria-label=""] { position: relative; }
.sub-tab-btn[aria-label=""]::before,
.sub-tab-btn[aria-label=""]::after,
.sub-tab-btn::after,
.sub-tab-btn::before {
    display: none !important;
    content: none !important;
}
.sub-tab-btn:focus,
.sub-tab-btn:active { outline: none; box-shadow: none; }
.sub-tab-btn:hover { color: #1e3a5f; background: white; }
.sub-tab-btn.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
    border-bottom-width: 3px;
    font-weight: 600;
    background-color: rgba(30, 58, 95, 0.05);
}
.sub-tab-content {
    display: none !important;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}
.sub-tab-content.active {
    display: block !important;
    opacity: 1;
    animation: none;
}

.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}
.integration-card {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}
.integration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}
.integration-header h5 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
}
.integration-body { min-height: 200px; }
.integration-logo { text-align: center; }
.logo-placeholder {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.integration-form .form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}
.integration-form .form-control { font-size: 0.9rem; }
.integration-form small { font-size: 0.75rem; }

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .tabs-nav {
        padding: 0.45rem 0.5rem;
        gap: 0.35rem;
        scroll-snap-type: none;
        overflow-x: hidden;
        flex-wrap: wrap;
    }
    #dashboard-section .tabs-nav {
        flex-wrap: wrap;
        overflow-x: hidden;
        overflow-y: visible;
    }
    .tabs-nav .tab-btn {
        flex: 1 1 auto;
        white-space: normal;
        overflow: visible;
        max-width: 100%;
        padding: 0.55rem 0.85rem;
        font-size: 0.78rem;
        letter-spacing: 0.02em;
        text-align: center;
    }
    .tabs-nav .tab-btn span {
        white-space: normal;
    }
    .sub-tabs-nav {
        padding: 0.5rem 0.75rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .sub-tabs-nav .sub-tab-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .main-content { padding: 1rem; }
    .integrations-grid { grid-template-columns: 1fr; }
}
