/* public/css/admin-cruds.css */

/* Layout de Pantalla Dividida */
.admin-dashboard {
    display: grid;
    gap: 25px;
    align-items: start;
}

@media (min-width: 992px) {
    .admin-dashboard {
        grid-template-columns: 320px 1fr;
    }
}

/* Variante APILADA: se usa solo donde la tabla tiene muchas columnas (ej. Agentes)
   y necesita todo el ancho disponible en vez de compartir fila con el formulario.
   Se agrega como clase adicional: class="admin-dashboard admin-dashboard--apilado" */
.admin-dashboard--apilado {
    grid-template-columns: 1fr !important;
}

/* Formularios y Cajas CRUD */
.formulario,
.table-container {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.formulario-caja {
    max-width: 450px;
    margin: 0 auto;
}

/* Variante GRID: distribuye los form-group en columnas horizontales para
   aprovechar el ancho completo (ej. Registrar Nuevo Agente cuando el formulario
   ya no comparte fila con la tabla). No afecta a .formulario normal. */
.formulario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 24px;
    align-items: start;
}

.formulario-grid .form-group {
    margin-bottom: 15px;
}

.formulario-grid .btn,
.formulario-grid button[type="submit"] {
    grid-column: 1 / -1;
    justify-self: start;
    min-width: 220px;
}

.box-title {
    margin-top: 0;
    font-size: 1.1rem;
    color: #003570;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

/* Inputs de Formularios CRUD */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #555;
}

.form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #3390d6;
    box-shadow: 0 0 0 3px rgba(0, 90, 173, 0.1);
}

.input-uppercase {
    text-transform: uppercase;
}

.text-ayuda {
    color: #8a97a5;
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
}

/* Estructuración de Tablas (DataTables) */
table.dataTable {
    font-size: 14px;
}

table.dataTable thead th {
    border-bottom: 2px solid #dee2e6 !important;
    color: #495057;
}

table.dataTable tbody td {
    padding: 14px 10px;
    vertical-align: middle;
}

table.dataTable tbody tr {
    transition: background-color 0.15s ease;
}

table.dataTable tbody tr:hover {
    background-color: #f8fafc;
}

table.dataTable tbody tr.odd {
    background-color: #fbfcfc;
}

table.dataTable tbody tr.even {
    background-color: #ffffff;
}

table.dataTable tbody tr.odd:hover,
table.dataTable tbody tr.even:hover {
    background-color: #f0f4f6;
}

table.dataTable tbody td:nth-child(2) {
    font-weight: 600;
    color: #003570;
}

table.dataTable tr.dtrg-group.dtrg-start td {
    background-color: #f4f7f6;
    color: #8a97a5;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 12px;
    border-top: 2px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

/* Acciones en Tablas */
.acciones-flex {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.acciones-flex form {
    margin: 0;
}

.acciones-flex .btn {
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 0.82rem;
}

/* Los botones Activar/Desactivar comparten el mismo ancho fijo para que las filas
   activas e inactivas ocupen exactamente el mismo espacio horizontal */
.acciones-flex form .btn.btn-danger,
.acciones-flex form .btn.btn-success {
    min-width: 76px;
    text-align: center;
}

.formulario-accion {
    margin: 0;
    padding: 0;
}

.btn-eliminar {
    background-color: #6c757d;
    color: #ffffff;
    border: none;
}

.btn-eliminar:hover {
    background-color: #5a6268;
    color: #ffffff;
    transform: translateY(-1px);
}

/* Estados y Badges */
.texto-estado-activo {
    color: #198754;
    font-weight: 700;
}

.texto-estado-inactivo {
    color: #dc3545;
    font-weight: 700;
}

.badge-rol {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-rol-admin {
    background-color: #fdf3d8;
    color: #b8860b;
    border: 1px solid #f1c40f;
}

.badge-rol-agente {
    background-color: #e8f2fc;
    color: #005aad;
    border: 1px solid #a8cce8;
}

.badge-servicios-count {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background-color: #d1e7dd;
    color: #0f5132;
    text-decoration: none;
    border: 1px solid #badbcc;
}

.badge-servicios-count:hover {
    background-color: #80b3e0;
}

.badge-servicios-vacio {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background-color: #f8d7da;
    color: #842029;
    text-decoration: none;
    border: 1px solid #f5c2c7;
}

.badge-servicios-vacio:hover {
    background-color: #f3c2c6;
}

.badge-servicios-na {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background-color: #f1f3f5;
    color: #8a97a5;
    border: 1px solid #e2e8f0;
}

/* Vista Asignar Servicios (Checkboxes) */
.lista-servicios-check {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.check-item {
    font-weight: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.check-item:hover {
    background-color: #f4f7f6;
}

.check-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #005aad;
}

.acciones-asignacion {
    display: flex;
    gap: 10px;
    margin-top: 28px;
}

.btn-guardar-asignacion {
    flex: 1;
    padding: 12px;
    font-size: 14px;
}

.btn-volver-asignacion {
    margin-left: 0;
    padding: 12px 20px;
    display: flex;
    align-items: center;
}

/* Tooltips */
.tiene-tooltip {
    position: relative;
}

.tiene-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #003570;
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    max-width: 280px;
    white-space: normal;
    text-align: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 20;
}

.tiene-tooltip::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #003570;
    margin-bottom: -4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 20;
}

.tiene-tooltip:hover::after,
.tiene-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Enlaces visuales */

/* Tooltip alineado a la izquierda para no salirse de pantalla en la última columna */
.enlaces-kiosco .tiene-tooltip::after {
    left: auto;
    right: 0;
    transform: none;
}

.enlaces-kiosco .tiene-tooltip::before {
    left: auto;
    right: 10px;
    transform: none;
}

.link-enlace {
    color: #005aad;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.link-enlace:hover {
    text-decoration: underline;
}

/* Gestión de categorías: colapsada dentro del formulario, junto al selector que la usa */

.categorias-count {
    color: #8a97a5;
    font-weight: 500;
}

.categorias-panel {
    margin-top: 14px;
}

.categorias-inline-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.categorias-inline-form .form-control {
    flex: 1;
}

.categorias-inline-form .btn {
    flex-shrink: 0;
    margin-top: 0;
    width: auto;
    padding: 10px 16px;
}

.categorias-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.categoria-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f4f7f6;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 5px 6px 5px 14px;
    font-size: 0.82rem;
    color: #003570;
}

.categoria-chip form {
    margin: 0;
    line-height: 0;
}

.categoria-chip-x {
    background: none;
    border: none;
    cursor: pointer;
    color: #8a97a5;
    font-size: 1rem;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 50%;
}

.categoria-chip-x:hover {
    background: #e74c3c;
    color: #fff;
}

/* =========================================
   Estilos de Flujo por Pasos (UI UX)
   ========================================= */

.step-container {
    margin-bottom: 5px;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.step-number {
    background-color: #003570;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.step-header .box-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
    font-weight: 700;
}

.step-divider {
    border: 0;
    border-top: 1px solid #e9ecef;
    margin: 25px 0;
}

.visible-panel {
    margin-top: 10px;
}

.btn-block {
    width: 100%;
    display: block;
    margin-top: 10px;
}