/*
 * ══════════════════════════════════════════════════════════════
 * GESTIONOMINA - Estilos Base de la Aplicación
 * ══════════════════════════════════════════════════════════════
 */

/* ── Reset y Base ── */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Sidebar ── */
.sidebar {
    transition: transform 0.3s ease, width 0.3s ease;
    overflow: hidden;
    width: 256px;
}

.sidebar .nav-link i {
    width: 24px;
    text-align: center;
    font-size: 1rem;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Sidebar collapsed (desktop) */
@media (min-width: 769px) {
    .sidebar.collapsed {
        width: 64px;
    }
    .sidebar.collapsed .logo span,
    .sidebar.collapsed .nav-link span,
    .sidebar.collapsed .sidebar-footer span {
        display: none;
    }
    .sidebar.collapsed .nav-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
    .sidebar.collapsed + main,
    .sidebar.collapsed ~ main {
        margin-left: 64px !important;
    }
}

/* Sidebar mobile overlay */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 256px;
        z-index: 40;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    #main-content {
        margin-left: 0 !important;
    }
}

/* Sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop.active {
    display: block;
}

/* ── Cards Animados ── */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-1px);
}

/* ── Tabla Responsiva ── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table th {
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ── Formularios ── */
.form-control, .form-select {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-control:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ── Botones ── */
.btn {
    transition: all 0.15s ease-in-out;
    font-weight: 500;
    font-size: 0.875rem;
}

.btn i {
    margin-right: 0.375rem;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ── Badges / Etiquetas ── */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.25em 0.65em;
}

/* ── Modal ── */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--color-border-light);
}

.modal-footer {
    border-top: 1px solid var(--color-border-light);
}

/* ── Loading Spinner ── */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Toast / Notificaciones ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    min-width: 300px;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

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

.toast-error {
    background: #f8d7da;
    border-left: 4px solid var(--color-danger);
    color: #721c24;
}

.toast-warning {
    background: #fff3cd;
    border-left: 4px solid var(--color-warning);
    color: #856404;
}

.toast-info {
    background: #d1ecf1;
    border-left: 4px solid var(--color-info);
    color: #0c5460;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Utilidades ── */
.text-primary { color: var(--color-primary) !important; }
.text-secondary { color: var(--color-secondary) !important; }
.text-accent { color: var(--color-accent) !important; }
.bg-primary { background-color: var(--color-primary) !important; }
.bg-secondary { background-color: var(--color-secondary) !important; }
.bg-accent { background-color: var(--color-accent) !important; }

.border-primary { border-color: var(--color-primary) !important; }

/* ── Reportes / Recibos ── */
.recibo-pago {
    max-width: 800px;
    margin: 0 auto;
    font-family: var(--font-primary);
}

.recibo-pago .header-recibo {
    background: var(--color-bg-header);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.recibo-pago .body-recibo {
    padding: 1.5rem;
    background: white;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Select2 Personalizado ── */
.select2-container--default .select2-selection--single {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    height: 38px;
    padding: 5px 10px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--color-text-primary);
    line-height: 26px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

/* ── Responsive: Móvil (hasta 640px) ── */
@media (max-width: 640px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
        font-size: 0.8125rem;
        padding: 0.75rem 1rem;
    }

    .recibo-pago .header-recibo {
        padding: 1rem;
    }

    .recibo-pago .body-recibo {
        padding: 1rem;
    }

    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
    }

    /* Tablas: ocultar columnas secundarias */
    .hide-mobile {
        display: none !important;
    }

    /* Tablas: texto más pequeño */
    table.text-responsive td,
    table.text-responsive th {
        font-size: 0.6875rem;
        padding: 0.375rem 0.25rem;
        white-space: nowrap;
    }
}

/* ── Responsive: Tablet (hasta 768px) ── */
@media (max-width: 768px) {
    .btn-group-responsive {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .btn-group-responsive .btn {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    .table-responsive-mobile {
        font-size: 0.8125rem;
    }

    .table-responsive-mobile th,
    .table-responsive-mobile td {
        padding: 0.5rem 0.375rem;
    }
}

/* ── Utilidades Responsive ── */
.stack-mobile {
    display: flex;
    flex-direction: column;
}

@media (min-width: 641px) {
    .stack-mobile {
        flex-direction: row;
        align-items: center;
    }
}

.text-truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .text-truncate-mobile {
        white-space: normal;
    }
}

/* ── Print ── */
@media print {
    .no-print { display: none !important; }

    .sidebar { display: none !important; }
    #main-content { margin-left: 0 !important; }
    .header { display: none !important; }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    body {
        font-size: 10pt;
        color: #000;
        background: #fff;
    }

    .table {
        font-size: 9pt;
    }
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD EJECUTIVO - Estilos
   ══════════════════════════════════════════════════════════════ */

/* ── Background Pattern Decorativo ── */
.dashboard-bg {
    background-color: var(--color-bg-secondary, #f3f4f6);
    background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,0.03) 1px, transparent 0);
    background-size: 32px 32px;
    min-height: calc(100vh - var(--header-height, 60px));
}

/* ── Animaciones de Entrada ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.dashboard-animate {
    animation: fadeInUp 0.5s ease-out both;
}

.dashboard-animate-delay-1 { animation-delay: 0.1s; }
.dashboard-animate-delay-2 { animation-delay: 0.2s; }
.dashboard-animate-delay-3 { animation-delay: 0.3s; }
.dashboard-animate-delay-4 { animation-delay: 0.4s; }
.dashboard-animate-delay-5 { animation-delay: 0.5s; }
.dashboard-animate-delay-6 { animation-delay: 0.6s; }

/* ── Header del Dashboard ── */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-primary, #212529);
    margin: 0;
}

.dashboard-header .dashboard-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary, #6c757d);
}

/* ── Selector de Período ── */
.periodo-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.periodo-selector label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary, #6c757d);
    margin: 0;
}

.periodo-selector select {
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    border: 1px solid var(--color-border, #dee2e6);
    border-radius: var(--radius-md, 8px);
    background-color: #fff;
    color: var(--color-text-primary, #212529);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.periodo-selector select:focus {
    outline: none;
    border-color: var(--color-primary, #1a5276);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 26,82,118), 0.15);
}

/* ── Tarjetas KPI ── */
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

@media (max-width: 1024px) {
    .dashboard-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .dashboard-kpi-grid { grid-template-columns: 1fr; }
}

.dashboard-kpi {
    position: relative;
    border-radius: var(--radius-lg, 12px);
    padding: 1.25rem 1.5rem;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.dashboard-kpi::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.dashboard-kpi::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
}

/* Colores KPI */
.kpi-blue { background: linear-gradient(135deg, #1a5276 0%, #2e86c1 100%); }
.kpi-green { background: linear-gradient(135deg, #1e8449 0%, #27ae60 100%); }
.kpi-purple { background: linear-gradient(135deg, #6c3483 0%, #8e44ad 100%); }
.kpi-orange { background: linear-gradient(135deg, #d35400 0%, #e67e22 100%); }

.dashboard-kpi .kpi-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.dashboard-kpi .kpi-info {
    flex: 1;
    min-width: 0;
}

.dashboard-kpi .kpi-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.85;
    margin-bottom: 0.375rem;
}

.dashboard-kpi .kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.375rem;
    animation: countUp 0.6s ease-out both;
}

.dashboard-kpi .kpi-variacion {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
}

.kpi-variacion.positiva { background: rgba(46,204,113,0.3); }
.kpi-variacion.negativa { background: rgba(231,76,60,0.3); }
.kpi-variacion.neutral { background: rgba(255,255,255,0.2); }

.dashboard-kpi .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md, 8px);
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.dashboard-kpi .kpi-sub {
    font-size: 0.6875rem;
    opacity: 0.75;
    margin-top: 0.125rem;
}

/* ── Cards de Gráficos ── */
.dashboard-charts-grid {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.dashboard-charts-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.dashboard-charts-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 1024px) {
    .dashboard-charts-grid.cols-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-charts-grid.cols-3,
    .dashboard-charts-grid.cols-2 {
        grid-template-columns: 1fr;
    }
}

.dashboard-chart-card {
    background: #fff;
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--color-border, #dee2e6);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.dashboard-chart-card:hover {
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0,0,0,0.1));
}

.dashboard-chart-card .chart-header {
    padding: 1rem 1.25rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dashboard-chart-card .chart-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-primary, #212529);
    margin: 0;
}

.dashboard-chart-card .chart-subtitle {
    font-size: 0.6875rem;
    color: var(--color-text-secondary, #6c757d);
    margin: 0.125rem 0 0;
}

.dashboard-chart-card .chart-body {
    padding: 0.25rem 0.75rem 0.75rem;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-chart-card .chart-body canvas,
.dashboard-chart-card .chart-body .apexcharts-canvas {
    width: 100% !important;
}

/* ── Secciones del Dashboard ── */
.dashboard-section {
    margin-bottom: 1.75rem;
}

.dashboard-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-primary, #212529);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-border-light, #f1f3f5);
}

.dashboard-section-title i {
    color: var(--color-primary, #1a5276);
}

/* ── Accesos Rápidos ── */
.dashboard-quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .dashboard-quick-actions {
        grid-template-columns: 1fr;
    }
}

.dashboard-quick-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--color-border, #dee2e6);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.dashboard-quick-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0,0,0,0.1));
    border-color: var(--color-primary, #1a5276);
    text-decoration: none;
    color: inherit;
}

.dashboard-quick-action .qa-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.dashboard-quick-action:hover .qa-icon {
    transform: scale(1.08);
}

.qa-icon.blue { background: linear-gradient(135deg, #1a5276, #2e86c1); }
.qa-icon.green { background: linear-gradient(135deg, #1e8449, #27ae60); }
.qa-icon.orange { background: linear-gradient(135deg, #d35400, #e67e22); }
.qa-icon.purple { background: linear-gradient(135deg, #6c3483, #8e44ad); }
.qa-icon.teal { background: linear-gradient(135deg, #148f77, #1abc9c); }

.dashboard-quick-action .qa-text h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-primary, #212529);
    margin: 0;
}

.dashboard-quick-action .qa-text p {
    font-size: 0.6875rem;
    color: var(--color-text-secondary, #6c757d);
    margin: 0.125rem 0 0;
}

/* ── Skeleton Loading ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #e9ecef 25%, #f1f3f5 50%, #e9ecef 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md, 8px);
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.375rem;
}

.skeleton-text.sm { width: 60%; }
.skeleton-text.md { width: 80%; }
.skeleton-text.lg { width: 40%; }

.skeleton-kpi {
    height: 100px;
    border-radius: var(--radius-lg, 12px);
}

.skeleton-chart {
    height: 280px;
    border-radius: var(--radius-lg, 12px);
}

/* ── Empty State ── */
.dashboard-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-secondary, #6c757d);
}

.dashboard-empty i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.dashboard-empty p {
    font-size: 0.875rem;
    margin: 0;
}

/* ── Last Updated ── */
.dashboard-updated {
    font-size: 0.6875rem;
    color: var(--color-text-secondary, #6c757d);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.dashboard-updated .dot-live {
    width: 6px;
    height: 6px;
    background: #27ae60;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Responsive Overrides ── */
@media (max-width: 640px) {
    .dashboard-kpi .kpi-value {
        font-size: 1.35rem;
    }

    .dashboard-kpi .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .dashboard-chart-card .chart-body {
        min-height: 220px;
    }
}

/* ── ApexCharts Theme Override ── */
.apexcharts-tooltip {
    font-family: var(--font-primary, 'Inter', sans-serif) !important;
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: var(--shadow-lg, 0 10px 15px rgba(0,0,0,0.1)) !important;
}

.apexcharts-legend-text {
    font-size: 0.75rem !important;
    font-weight: 500 !important;
}
