/* LC Solar Data Plugin Styles v2.0 */
.lc-solar-container {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border: 2px solid #00a89c;
    border-radius: 15px;
    padding: 25px;
    margin: 25px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 8px 25px rgba(0, 168, 156, 0.15);
}

.lc-solar-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.lc-solar-header h3 {
    color: #006654;
    margin: 0 0 8px 0;
    font-size: 2em;
    font-weight: 700;
}

.lc-solar-subtitle {
    color: #6c757d;
    margin: 0;
    font-size: 1.1em;
    font-weight: 500;
}

/* Grid de tarjetas principales */
.lc-solar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.lc-solar-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border-left: 5px solid #00a89c;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.lc-solar-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 168, 156, 0.2);
}

.lc-solar-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #00a89c, #006654);
}

.lc-solar-icon {
    font-size: 2.5em;
    margin-right: 15px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
}

.lc-solar-content h4 {
    margin: 0 0 5px 0;
    color: #495057;
    font-size: 1em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lc-solar-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #006654;
    display: block;
}

/* Colores específicos por tipo de tarjeta */
.lc-card-main { border-left-color: #007bff; }
.lc-card-main::before { background: linear-gradient(90deg, #007bff, #0056b3); }

.lc-card-income { border-left-color: #28a745; }
.lc-card-income::before { background: linear-gradient(90deg, #28a745, #1e7e34); }

.lc-card-today { border-left-color: #ffc107; }
.lc-card-today::before { background: linear-gradient(90deg, #ffc107, #e0a800); }

.lc-card-consumption { border-left-color: #fd7e14; }
.lc-card-consumption::before { background: linear-gradient(90deg, #fd7e14, #e55a00); }

.lc-card-income-today { border-left-color: #20c997; }
.lc-card-income-today::before { background: linear-gradient(90deg, #20c997, #17a085); }

.lc-card-month { border-left-color: #6f42c1; }
.lc-card-month::before { background: linear-gradient(90deg, #6f42c1, #59359a); }

/* Estado del sistema */
.lc-solar-status {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.lc-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
}

.lc-status-indicator.status-ok {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.lc-status-indicator.status-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-icon {
    font-size: 1.2em;
}

/* Sección de inversores */
.lc-solar-inverters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.lc-inverter-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    position: relative;
}

.lc-inverter-large {
    border-top: 4px solid #007bff;
}

.lc-inverter-small {
    border-top: 4px solid #28a745;
}

.lc-inverter-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.lc-inverter-header h4 {
    margin: 0 0 5px 0;
    color: #495057;
    font-size: 1.3em;
}

.lc-inverter-sn {
    font-size: 0.9em;
    color: #6c757d;
    font-family: monospace;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
}

.lc-inverter-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lc-stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.lc-stat {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid #00a89c;
}

.lc-stat .label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.lc-stat .value {
    font-weight: 700;
    color: #006654;
    font-size: 1.1em;
}

.lc-stat .value.temp {
    color: #dc3545;
}

.lc-stat .value.status-ok {
    color: #28a745;
}

.lc-stat .value.status-warning {
    color: #ffc107;
}

/* ======= NUEVOS ESTILOS HISTÓRICO - MISMO SISTEMA QUE INVERSORES ======= */

/* Sección histórica usando el MISMO sistema que inversores */
.lc-historical-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

/* Tarjeta de resumen histórico - IGUAL que lc-inverter-card */
.lc-historical-stats {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    position: relative;
    border-top: 4px solid #6f42c1;
}

/* Header del resumen - IGUAL que lc-inverter-header */
.lc-historical-stats .lc-hist-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.lc-historical-stats .lc-hist-header h4 {
    margin: 0 0 5px 0;
    color: #495057;
    font-size: 1.3em;
}

/* Grid de estadísticas - IGUAL que lc-inverter-stats */
.lc-hist-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Filas de stats - IGUAL que lc-stat-row */
.lc-hist-stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Tarjetas individuales - IGUAL que lc-stat */
.lc-stat-card {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid #00a89c;
}

.lc-stat-card .stat-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.lc-stat-card .stat-value {
    font-weight: 700;
    color: #006654;
    font-size: 1.1em;
}

/* Colores específicos para cada stat histórico */
.lc-stat-card:nth-child(1) { border-left-color: #007bff; }
.lc-stat-card:nth-child(2) { border-left-color: #28a745; }
.lc-stat-card:nth-child(3) { border-left-color: #ffc107; }
.lc-stat-card:nth-child(4) { border-left-color: #fd7e14; }

/* Sección del gráfico - IGUAL que lc-inverter-card */
.lc-historical-chart {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
    margin-bottom: 25px;
}

.lc-chart-container {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    position: relative;
    border-top: 4px solid #20c997;
}

/* Header del gráfico - IGUAL que lc-inverter-header */
.lc-chart-container .lc-chart-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.lc-chart-container .lc-chart-header h4 {
    margin: 0 0 5px 0;
    color: #495057;
    font-size: 1.3em;
}

/* Canvas y placeholder */
#lc-solar-chart {
    max-width: 100%;
    height: 300px !important;
    margin: 0 auto;
    display: block;
}

.lc-chart-placeholder {
    text-align: center;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 15px 0;
}

.lc-chart-placeholder p {
    margin: 0 0 15px 0;
    color: #6c757d;
    font-size: 1.1em;
    font-weight: 500;
}

.lc-chart-placeholder pre {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
    max-height: 200px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.4;
    color: #495057;
}

/* Avisos y errores - IGUAL que el sistema existente */
.lc-solar-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.lc-solar-warning p {
    margin: 0 0 10px 0;
    font-weight: 600;
}

.lc-solar-warning small {
    color: #6c757d;
    font-size: 0.85em;
}

/* Footer */
.lc-solar-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.lc-solar-footer small {
    color: #6c757d;
    font-style: italic;
}

/* Error styles */
.lc-solar-error {
    text-align: center;
    padding: 30px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 10px;
}

.lc-solar-error h3 {
    margin: 0 0 10px 0;
    color: #721c24;
}

/* Responsive Design */
@media (max-width: 768px) {
    .lc-solar-container {
        padding: 20px 15px;
        margin: 15px 0;
    }

    .lc-solar-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .lc-solar-card {
        padding: 15px;
    }

    .lc-solar-icon {
        font-size: 2em;
        margin-right: 10px;
    }

    .lc-solar-value {
        font-size: 1.5em;
    }

    .lc-solar-inverters,
    .lc-historical-summary,
    .lc-historical-chart {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .lc-stat-row,
    .lc-hist-stat-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .lc-inverter-card,
    .lc-historical-stats,
    .lc-chart-container {
        padding: 20px 15px;
    }
}

@media (max-width: 480px) {
    .lc-solar-header h3 {
        font-size: 1.5em;
    }

    .lc-solar-card {
        flex-direction: column;
        text-align: center;
    }

    .lc-solar-icon {
        margin: 0 0 10px 0;
    }
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lc-solar-container {
    animation: fadeInUp 0.6s ease-out;
}

.lc-solar-card {
    animation: fadeInUp 0.6s ease-out;
}

.lc-solar-card:nth-child(1) { animation-delay: 0.1s; }
.lc-solar-card:nth-child(2) { animation-delay: 0.2s; }
.lc-solar-card:nth-child(3) { animation-delay: 0.3s; }
.lc-solar-card:nth-child(4) { animation-delay: 0.4s; }
.lc-solar-card:nth-child(5) { animation-delay: 0.5s; }
.lc-solar-card:nth-child(6) { animation-delay: 0.6s; }


/* Estilos simples para histórico */
.lc-data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.lc-data-table th,
.lc-data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.lc-data-table th {
    background: #f8f9fa;
    font-weight: 600;
}

.lc-data-table tbody tr:hover {
    background: #f8f9fa;
}

.lc-solar-info {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.lc-solar-info ul {
    margin: 15px 0;
    padding-left: 20px;
}

.lc-esconder {
    display: none;
}

/* ==========================================================================
   Estilos para el Gráfico Histórico Interactivo
   ========================================================================== */

/* Contenedor de los botones de período (Semana, Mes, Año) */
.lc-solar-chart-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

/* Estilo de cada botón de período */
.lc-solar-period-btn {
    background-color: #f8f9fa; /* Fondo gris claro, como el de los stats */
    border: 1px solid #dee2e6;
    border-radius: 8px; /* Menos ovalado */
    padding: 8px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d; /* Color de texto secundario */
    transition: all 0.3s ease;
}

/* Estilo del botón cuando está activo (seleccionado) */
.lc-solar-period-btn.active {
    background-color: #00a89c; /* Color principal del sistema */
    color: #fff;
    border-color: #00a89c;
    box-shadow: 0 4px 15px rgba(0, 168, 156, 0.2);
}

/* Estilo del botón al pasar el ratón por encima (si no está activo) */
.lc-solar-period-btn:not(.active):hover {
    background-color: #e9ecef;
    border-color: #ced4da;
    color: #495057;
}

/* Contenedor que envuelve el gráfico y el spinner */
.lc-solar-chart-container {
    position: relative;
    height: 400px;
    width: 100%;
    margin-bottom: 20px;
}

/* Animación de carga (spinner) */
.lc-solar-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #00a89c; /* Color principal del sistema */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Animación de rotación para el spinner */
@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==========================================================================
   Estilos para la Tabla Histórica
   ========================================================================== */

.lc-historical-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.lc-historical-table th,
.lc-historical-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.lc-historical-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.lc-historical-table tbody tr:hover {
    background-color: #f1f1f1;
}

/* ==========================================================================
   Estilos para el Gráfico Histórico Interactivo
   ========================================================================== */

/* Contenedor de los botones de período (Semana, Mes, Año) */
.lc-solar-chart-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

/* Estilo de cada botón de período */
.lc-solar-period-btn {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s ease;
}

/* Estilo del botón cuando está activo (seleccionado) */
.lc-solar-period-btn.active {
    background-color: #00a89c;
    color: #fff;
    border-color: #00a89c;
    box-shadow: 0 4px 15px rgba(0, 168, 156, 0.2);
}

/* Estilo del botón al pasar el ratón por encima (si no está activo) */
.lc-solar-period-btn:not(.active):hover {
    background-color: #e9ecef;
    border-color: #ced4da;
    color: #495057;
}

/* Contenedor que envuelve el gráfico y el spinner */
.lc-solar-chart-container {
    position: relative;
    height: 400px;
    width: 100%;
    margin-bottom: 20px;
}

/* Animación de carga (spinner) */
.lc-solar-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #00a89c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Animación de rotación para el spinner */
@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==========================================================================
   Estilos para la Tabla Histórica (Mejorados)
   ========================================================================== */

.lc-historical-table-wrapper {
    width: 100%;
    overflow-x: auto; /* Permitir scroll horizontal siempre que sea necesario */
    -webkit-overflow-scrolling: touch;
}

.lc-historical-table {
    width: 100%;
    min-width: 800px; /* Ancho mínimo para que las columnas no se aplasten en PC */
    border-collapse: collapse;
    margin-top: 20px;
}

.lc-historical-table th,
.lc-historical-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
}

.lc-historical-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.lc-historical-table tbody tr:hover {
    background-color: #f1f1f1;
}

/* ==========================================================================
   NUEVO: Indicador de scroll para móviles
   ========================================================================== */

@media (max-width: 768px) {
    .lc-historical-table-wrapper {
        position: relative; /* Necesario para el pseudo-elemento */
    }

    /* Sombra que indica que hay más contenido a la derecha */
    .lc-historical-table-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff 70%);
        pointer-events: none; /* Permite hacer scroll sobre la sombra */
    }
}


