/* ==========================
   PAGE HEADER
========================== */

.page-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f1f5f9;
}

.page-header h2 {
    margin-bottom: 8px;
    color: var(--text-primary, #0f172a);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 2rem;
}

.page-header h2 span {
    font-size: 2rem;
}

.page-header p {
    color: var(--text-secondary, #64748b);
    font-size: 0.95rem;
    margin: 0;
}

/* ==========================
   SECTION HEADER
========================== */

.section-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h3 {
    margin: 0;
    color: var(--text-primary, #0f172a);
    font-size: 1.5rem;
}

.section-subtitle {
    color: var(--text-secondary, #64748b);
    font-size: 0.9rem;
    display: block;
    margin-top: 4px;
}

/* ==========================
   ACTION BUTTONS
========================== */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 32px;
}

.action-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ==========================
   DASHBOARD NAV / PAGE ACTIONS
========================== */

.dashboard-nav,
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid #f1f5f9;
}

/* ==========================
   TABLE INFO (Header de tabla)
========================== */

.table-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==========================
   BREADCRUMB
========================== */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary, #64748b);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-item a {
    color: var(--primary, #6366f1);
    text-decoration: none;
    transition: color var(--transition-fast, 150ms);
}

.breadcrumb-item a:hover {
    color: var(--primary-dark, #4f46e5);
    text-decoration: underline;
}

.breadcrumb-item::after {
    content: '/';
    color: var(--text-secondary, #64748b);
    margin-left: 8px;
}

.breadcrumb-item:last-child::after {
    display: none;
}

.breadcrumb-item.active {
    color: var(--text-primary, #0f172a);
    font-weight: 600;
}

/* ==========================
   DIVIDER
========================== */

.divider {
    height: 1px;
    background: #e2e8f0;
    margin: 24px 0;
}

.divider-thick {
    height: 2px;
    background: #f1f5f9;
}

/* ==========================
   EMPTY STATE
========================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #64748b);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* ==========================
   GRID LAYOUTS
========================== */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* ==========================
   TABS / PESTAÑAS
========================== */

.tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-card, #ffffff);
    padding: 12px;
    border-radius: var(--radius-md, 10px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    background: transparent;
    border: 2px solid transparent;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: all var(--transition-base, 250ms);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.05), transparent);
    transition: left var(--transition-base, 250ms);
}

.tab:hover::before {
    left: 100%;
}

.tab:hover {
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary, #6366f1);
    border-color: rgba(99, 102, 241, 0.2);
}

.tab.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-color: #6366f1;
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.tab.active:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-color: #4f46e5;
}

.tab.loading {
    opacity: 0.6;
    pointer-events: none;
}

.tab.loading::after {
    content: '⏳';
    margin-left: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ==========================
   CONTENEDOR AJAX
========================== */

#ajax-tabla-container {
    min-height: 200px;
    position: relative;
}

#ajax-tabla-container.loading {
    opacity: 0.5;
    pointer-events: none;
}

#ajax-tabla-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* ==========================
   DASHBOARD — HERO DE BIENVENIDA
   Reemplaza .page-header en dashboards
========================== */

.dash-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.dash-eyebrow {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    margin-bottom: 4px;
}

.dash-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 4px;
    line-height: 1.2;
    /* anula el gradiente de h2 en base.css */
    background: none;
    -webkit-text-fill-color: var(--text-primary);
}

.dash-name {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.dash-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

/* CTA del hero — extiende .btn.btn-primary de buttons.css */
.dash-cta {
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.dash-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.45);
}

/* ==========================
   DASHBOARD — HELPERS DE TEXTO
========================== */

/* Etiqueta de sección (encima de stats-grid) */
.dash-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Link sutil en cabecera de .card */
.dash-link {
    font-size: 0.78rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}

.dash-link:hover {
    opacity: 0.7;
    color: var(--primary-dark);
}

/* Punto de color (sucursales) */
.dash-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Pill de cantidad junto a monto */
.dash-count-pill {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-left: 6px;
    font-weight: 500;
}

/* Mensaje de lista vacía dentro de .card */
.dash-empty-msg {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ==========================
   DASHBOARD — NAVEGACIÓN RÁPIDA
   Grid de accesos directos
========================== */

.dash-nav-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.dash-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 12px;
    background: var(--bg-card);
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    transition: all var(--transition-base);
    line-height: 1.3;
}

.dash-nav-item:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f5f3ff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.dash-nav-icon {
    font-size: 1.4rem;
    line-height: 1;
}

/* ==========================
   RESPONSIVE
========================== */

@media screen and (max-width: 900px) {
    .dash-nav-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .page-header h2 {
        font-size: 1.5rem;
    }

    .page-header h2 span {
        font-size: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header h3 {
        font-size: 1.25rem;
    }

    .action-buttons {
        flex-direction: column;
        margin-bottom: 24px;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .dashboard-nav,
    .page-actions {
        flex-direction: column;
    }

    .dashboard-nav .btn,
    .page-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .breadcrumb {
        font-size: 0.85rem;
    }

    .empty-state {
        padding: 40px 16px;
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .tabs {
        padding: 8px;
        gap: 6px;
    }

    .tab {
        min-width: 100px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Dashboard responsive */
    .dash-hero {
        flex-direction: column;
    }

    .dash-cta {
        width: 100%;
        justify-content: center;
    }

    .dash-title {
        font-size: 1.35rem;
    }
}