/* ==========================================================================
   BIENESTAR 2026 - COMPONENTES DE INTERFAZ DE USUARIO
   Tablas de alto rendimiento, modales deslizables, tarjetas y formularios
   ========================================================================== */

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-wine) 0%, #6b142e 100%);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 14px var(--brand-wine-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-wine-hover) 0%, #7d1736 100%);
    box-shadow: 0 6px 18px var(--brand-wine-glow);
    color: #ffffff;
}

.btn-gold {
    background: linear-gradient(135deg, #d4af37 0%, #a8841d 100%);
    color: #0d1726;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.25);
}

.btn-gold:hover {
    background: linear-gradient(135deg, #e2be49 0%, #b89124 100%);
    box-shadow: 0 6px 18px rgba(212, 175, 55, 0.35);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline-danger {
    background: transparent;
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
}

.btn-warning {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
    font-weight: 600;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: rgba(245, 158, 11, 0.7);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

.badge-history-alert {
    background: rgba(234, 179, 8, 0.12);
    color: #fde047;
    border: 1px solid rgba(234, 179, 8, 0.35);
    font-size: 0.76rem;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
    line-height: 1.3;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-icon-only {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
}

/* ==========================================================================
   TARJETAS Y MÉTRICAS (STATS GRID)
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.5rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-medium);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.icon-wine {
    background: rgba(139, 30, 63, 0.2);
    color: #f43f5e;
}

.icon-gold {
    background: rgba(212, 175, 55, 0.15);
    color: var(--brand-gold);
}

.icon-emerald {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}

.icon-blue {
    background: rgba(2, 132, 199, 0.15);
    color: #38bdf8;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.5rem;
}

.stat-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ==========================================================================
   BARRA DE BÚSQUEDA Y HERRAMIENTAS (TOOLBAR)
   ========================================================================== */
.toolbar-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 1;
    min-width: 280px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    color: #ffffff;
    font-size: 0.92rem;
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--brand-gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    background: #172740;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-select {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.7rem 1rem;
    color: var(--text-primary);
    font-size: 0.88rem;
    cursor: pointer;
    min-width: 150px;
    outline: none;
}

.filter-select:focus {
    border-color: var(--brand-gold);
}

/* ==========================================================================
   TABLA DE DATOS DE ALTO RENDIMIENTO
   ========================================================================== */
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.data-table th {
    background: var(--bg-surface-elevated);
    color: var(--text-secondary);
    padding: 0.95rem 1.25rem;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-medium);
    white-space: nowrap;
}

.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background-color: var(--bg-surface-hover);
}

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

/* Beneficiario en Tabla */
.beneficiary-cell {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.beneficiary-name {
    font-weight: 700;
    color: #ffffff;
    font-size: 0.95rem;
    letter-spacing: -0.2px;
}

.beneficiary-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Badges e Indicadores */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-wine {
    background: var(--brand-wine-glow);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-gold {
    background: var(--brand-gold-subtle);
    color: var(--brand-gold);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.badge-emerald {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-blue {
    background: var(--color-info-bg);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-gray {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

/* Barra de Progreso de Completitud */
.progress-container {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 140px;
}

.progress-track {
    flex: 1;
    height: 7px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--brand-wine) 0%, var(--brand-gold) 100%);
    transition: width var(--transition-normal);
}

.progress-bar.complete {
    background: var(--color-success);
}

.progress-pct {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    width: 34px;
}

/* Barra de Paginación */
.pagination-container {
    padding: 1.15rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 0.65rem;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--brand-gold);
}

.page-btn.active {
    background: var(--brand-wine);
    border-color: var(--brand-wine);
    color: #fff;
}

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

/* ==========================================================================
   DRAWER / MODAL DESLIZANTE PARA COMPLETAR DATOS
   ========================================================================== */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 9, 18, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.drawer-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.drawer-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-surface);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    pointer-events: none;
    transition: transform var(--transition-normal);
}

.drawer-backdrop.active .drawer-panel {
    transform: translateY(0);
    pointer-events: auto;
}

.drawer-header {
    padding: 1.25rem 2.5rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-elevated);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-shrink: 0;
}

.drawer-header-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.drawer-header-info h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 0;
}

.drawer-header-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.btn-close-drawer {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-close-drawer:hover {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Grilla Superior del Modal */
.drawer-top-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    padding: 1.25rem 2.5rem 0.5rem 2.5rem;
    flex-shrink: 0;
}

/* Aviso de Privacidad y Blindaje de Datos */
.privacy-banner {
    background: rgba(2, 132, 199, 0.1);
    border-left: 4px solid var(--color-info);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    font-size: 0.85rem;
    color: #bae6fd;
    line-height: 1.5;
    margin: 0;
}

/* Selector Especial de Gestor Bienestar */
.gestor-assign-card {
    background: linear-gradient(135deg, rgba(139, 30, 63, 0.18) 0%, rgba(197, 155, 39, 0.12) 100%);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin: 0;
}

.gestor-assign-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gestor-assign-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

/* Pestañas de Categoría en Modal */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 2.5rem 0 2.5rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-subtle);
    scrollbar-width: thin;
    flex-shrink: 0;
}

.tab-btn {
    padding: 0.75rem 1.15rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: #ffffff;
}

.tab-btn.active {
    color: var(--brand-gold);
    border-bottom-color: var(--brand-gold);
}

.tab-count-badge {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.tab-btn.active .tab-count-badge {
    background: var(--brand-wine);
    color: #fff;
}

/* Cuerpo del Modal */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
    display: block;
    width: 100%;
}

/* Grilla Multi-Columna Amplia para los Campos */
.category-panel {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important;
    gap: 1.5rem 2.25rem !important;
    align-content: start;
    width: 100%;
}

.category-panel[style*="display: none"],
.category-panel.hidden {
    display: none !important;
}

.field-group {
    margin-bottom: 0.25rem;
    display: flex;
    flex-direction: column;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.field-badge-empty {
    font-size: 0.68rem;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.field-badge-filled {
    font-size: 0.68rem;
    color: var(--color-success);
    background: var(--color-success-bg);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.field-badge-optional {
    font-size: 0.68rem;
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.field-input, .field-select, .field-textarea {
    width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: #ffffff;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.field-input:focus, .field-select:focus, .field-textarea:focus {
    outline: none;
    border-color: var(--brand-gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    background: #172740;
}

.field-input:disabled, .field-select:disabled, .field-textarea:disabled {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-subtle);
    color: var(--text-muted);
    cursor: not-allowed;
    font-style: italic;
}

.field-textarea {
    min-height: 80px;
    resize: vertical;
}

.field-group:has(.field-textarea) {
    grid-column: 1 / -1;
}

.drawer-footer {
    padding: 1.25rem 2.5rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-elevated);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    flex-shrink: 0;
}

/* ==========================================================================
   TOAST NOTIFICACIONES FLOTANTES
   ========================================================================== */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 440px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.15rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: #ffffff;
    transform: translateY(20px);
    opacity: 0;
    transition: all var(--transition-normal);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast-error {
    border-left: 4px solid var(--color-danger);
}

.toast-info {
    border-left: 4px solid var(--brand-gold);
}

/* ==========================================================================
   ESTADO VACÍO (EMPTY STATE)
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.4rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    max-width: 420px;
    margin: 0 auto;
}
