/* ============================================================
   HAMITO DATATABLE - Sistema de Tablas Responsivas Premium
   Componente reutilizable para todos los módulos del sistema.
   ============================================================ */

/* --- Contenedor Principal --- */
.ht-datatable-wrapper {
    position: relative;
}

/* --- Barra de Herramientas (buscar + info) --- */
.ht-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.ht-search {
    position: relative;
    flex: 0 0 280px;
}

.ht-search input {
    width: 100%;
    padding: 0.55rem 0.85rem 0.55rem 2.4rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
    transition: all 0.25s ease;
    color: #1e293b;
}

.ht-search input:focus {
    outline: none;
    border-color: var(--primary-color, #1e3a5f);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08);
    background: #fff;
}

.ht-search::before {
    content: "\F52A"; /* bi-search */
    font-family: "bootstrap-icons";
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
    pointer-events: none;
}

.ht-info {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
}

/* --- Tabla Principal --- */
.ht-table-container {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.ht-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Encabezados */
.ht-table thead th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.65rem 0.85rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    user-select: none;
    position: relative;
}

.ht-table thead th.sortable {
    cursor: pointer;
    padding-right: 1.6rem;
}

.ht-table thead th.sortable::after {
    content: "\F148"; /* bi-chevron-expand */
    font-family: "bootstrap-icons";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    opacity: 0.4;
}

.ht-table thead th.sort-asc::after {
    content: "\F145"; /* bi-chevron-up */
    opacity: 1;
    color: var(--primary-color, #1e3a5f);
}

.ht-table thead th.sort-desc::after {
    content: "\F13C"; /* bi-chevron-down */
    opacity: 1;
    color: var(--primary-color, #1e3a5f);
}

/* Celdas */
.ht-table tbody td {
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

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

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

.ht-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Botón Expandir (+) para Responsive --- */
.ht-expand-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.ht-expand-btn:hover {
    border-color: var(--primary-color, #1e3a5f);
    color: var(--primary-color, #1e3a5f);
    background: var(--primary-light, #e0e7ff);
}

.ht-expand-btn.expanded {
    background: var(--primary-color, #1e3a5f);
    border-color: var(--primary-color, #1e3a5f);
    color: #fff;
    transform: rotate(45deg);
}

/* Fila de detalle expandida */
.ht-detail-row td {
    padding: 0 !important;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.ht-detail-content {
    padding: 0.75rem 1rem 0.75rem 3rem;
}

.ht-detail-item {
    display: flex;
    padding: 0.35rem 0;
    font-size: 0.82rem;
    border-bottom: 1px solid #f1f5f9;
}

.ht-detail-item:last-child {
    border-bottom: none;
}

.ht-detail-label {
    font-weight: 600;
    color: #64748b;
    min-width: 120px;
    flex-shrink: 0;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    padding-top: 0.1rem;
}

.ht-detail-value {
    color: #334155;
}

/* --- Paginación --- */
.ht-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.ht-pagination-info {
    font-size: 0.78rem;
    color: #94a3b8;
}

.ht-pagination-buttons {
    display: flex;
    gap: 0.25rem;
}

.ht-page-btn {
    padding: 0.35rem 0.65rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    border-radius: 0.4rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Inter', sans-serif;
}

.ht-page-btn:hover:not(:disabled) {
    border-color: var(--primary-color, #1e3a5f);
    color: var(--primary-color, #1e3a5f);
    background: var(--primary-light, #e0e7ff);
}

.ht-page-btn.active {
    background: var(--primary-color, #1e3a5f);
    border-color: var(--primary-color, #1e3a5f);
    color: #fff;
}

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

/* --- Estado vacío / cargando / error --- */
.ht-status {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #94a3b8;
    font-size: 0.85rem;
}

.ht-status i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.ht-loading-bar {
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-color, #1e3a5f), transparent);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    animation: htLoadingSlide 1.2s ease-in-out infinite;
    border-radius: 2px;
}

@keyframes htLoadingSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* --- Botones de Acción dentro de la tabla --- */
.ht-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
}

.ht-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.ht-action-btn:hover {
    background: var(--primary-color, #1e3a5f);
    border-color: var(--primary-color, #1e3a5f);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ht-action-btn.danger:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.ht-action-btn.success:hover {
    background: #10b981;
    border-color: #10b981;
}

/* --- Columna del expand: compacta --- */
.ht-col-expand {
    width: 36px;
    text-align: center;
    padding-left: 0.5rem !important;
    padding-right: 0.25rem !important;
}

/* --- RESPONSIVE: Breakpoints --- */

/* Tablet portrait */
@media (max-width: 991.98px) {
    .ht-search {
        flex: 1 1 100%;
    }
    .ht-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    .ht-table {
        font-size: 0.8rem;
    }
    .ht-table thead th {
        font-size: 0.7rem;
        padding: 0.5rem 0.6rem;
    }
    .ht-table tbody td {
        padding: 0.45rem 0.6rem;
    }
    .ht-pagination {
        flex-direction: column;
        align-items: center;
    }
    .ht-detail-content {
        padding-left: 1.5rem;
    }
}
