/* ============================================================================
   Chart/Table Toggle Styles - Microsoft Copilot Inspired
   ============================================================================
   Estilos para los controles de alternancia entre vista de gráfico y tabla
   Compatible con modo oscuro y responsive design
   ============================================================================ */

/* ========================================================================
   Chart Container with Toggle
   ======================================================================== */

.chart-with-toggle {
    position: relative;
    width: 100%;
    margin: 16px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

/* ========================================================================
   Toggle Controls (Top Right)
   ======================================================================== */

.chart-toggle-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chart-view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chart-view-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.chart-view-btn.active {
    background: #0078d4;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 120, 212, 0.3);
}

.chart-view-btn .icon {
    font-size: 16px;
    line-height: 1;
}

.chart-view-btn .label {
    font-size: 13px;
}

/* Mobile: Solo mostrar iconos */
@media (max-width: 600px) {
    .chart-view-btn .label {
        display: none;
    }

    .chart-view-btn {
        padding: 8px;
    }

    .chart-toggle-controls {
        padding: 3px;
        gap: 2px;
    }
}

/* ========================================================================
   Chart/Table Views
   ======================================================================== */

.chart-view,
.table-view {
    display: none;
    padding: 16px;
    min-height: 300px;
}

.chart-view.active,
.table-view.active {
    display: block;
}

/* ========================================================================
   Table Styles (Syncfusion-inspired)
   ======================================================================== */

.chart-table-view {
    width: 100%;
    overflow-x: auto;
}

.sf-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #ffffff;
}

.sf-grid-table thead {
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
}

.sf-grid-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.sf-grid-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.2s ease;
}

.sf-grid-table tbody tr:hover {
    background: #f9f9f9;
}

.sf-grid-table tbody tr:last-child {
    border-bottom: none;
}

.sf-grid-table td {
    padding: 12px 16px;
    color: #666;
}

/* Números alineados a la derecha */
.sf-grid-table td:has(> :is(number, [data-type="number"])) {
    text-align: right;
}

/* ========================================================================
   No Data Message
   ======================================================================== */

.no-data {
    padding: 48px 24px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ========================================================================
   Dark Mode Support
   ======================================================================== */

@media (prefers-color-scheme: dark) {
    .chart-with-toggle {
        background: #1e1e1e;
        border-color: #3a3a3a;
    }

    .chart-toggle-controls {
        background: rgba(30, 30, 30, 0.95);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .chart-view-btn {
        color: #ccc;
    }

    .chart-view-btn:hover {
        background: #2a2a2a;
        color: #fff;
    }

    .chart-view-btn.active {
        background: #0078d4;
        color: #ffffff;
    }

    .sf-grid-table {
        background: #1e1e1e;
    }

    .sf-grid-table thead {
        background: #2a2a2a;
        border-bottom-color: #3a3a3a;
    }

    .sf-grid-table th {
        color: #e0e0e0;
    }

    .sf-grid-table tbody tr {
        border-bottom-color: #3a3a3a;
    }

    .sf-grid-table tbody tr:hover {
        background: #2a2a2a;
    }

    .sf-grid-table td {
        color: #ccc;
    }

    .no-data {
        color: #666;
    }
}

/* ========================================================================
   Animation
   ======================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-view.active,
.table-view.active {
    animation: fadeIn 0.3s ease;
}

/* ========================================================================
   Print Support
   ======================================================================== */

@media print {
    .chart-toggle-controls {
        display: none;
    }

    .chart-view,
    .table-view {
        display: block !important;
        page-break-inside: avoid;
    }

    .table-view {
        display: none !important; /* Solo imprimir gráfico por defecto */
    }

    .chart-view.active + .table-view {
        display: none !important;
    }
}

/* ========================================================================
   Responsive Adjustments
   ======================================================================== */

@media (max-width: 768px) {
    .chart-with-toggle {
        margin: 12px 0;
        border-radius: 6px;
    }

    .chart-view,
    .table-view {
        padding: 12px;
    }

    .sf-grid-table th,
    .sf-grid-table td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .chart-toggle-controls {
        top: 8px;
        right: 8px;
    }

    .chart-view,
    .table-view {
        padding: 8px;
    }

    .sf-grid-table {
        font-size: 12px;
    }

    .sf-grid-table th,
    .sf-grid-table td {
        padding: 8px 10px;
    }
}

/* ========================================================================
   Accessibility
   ======================================================================== */

.chart-view-btn:focus {
    outline: 2px solid #0078d4;
    outline-offset: 2px;
}

.chart-view-btn:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chart-with-toggle {
        border: 2px solid currentColor;
    }

    .chart-view-btn {
        border: 1px solid currentColor;
    }

    .chart-view-btn.active {
        background: HighlightText;
        color: Highlight;
    }
}
