/* ====================================================================
   SOLARCONTROL - Sistema Profesional de Gestión Económica Fotovoltaica
   Hoja de Estilos CSS3 Principal (Puro, Modular, Sin Frameworks)
   Versión: 1.0 (Etapa 1)
   ==================================================================== */

/* --- 1. Variables Globales y Paleta de Colores (Diseño Premium) --- */
:root {
    /* Colores Principales */
    --primary: #1e293b;        /* Slate 800 - Fondo oscuro corporate */
    --primary-light: #334155;  /* Slate 700 */
    --primary-dark: #0f172a;   /* Slate 900 */
    --accent-gold: #f59e0b;    /* Ámbar Solar - Energía Solar */
    --accent-orange: #f97316;  /* Naranja */
    --accent-green: #10b981;   /* Emerald - Ahorros e Inyección */
    --accent-blue: #3b82f6;    /* Azul - Consumos */
    --accent-red: #ef4444;     /* Rojo - Compras a Red */
    --accent-purple: #8b5cf6;  /* Púrpura - Independencia */
    --accent-teal: #0d9488;    /* Teal - Baterías */

    /* Neutros */
    --bg-light: #f8fafc;       /* Off-white */
    --bg-dark: #0f172a;        /* Fondo oscuro para login */
    --card-bg: #ffffff;
    --border-color: #e2e8f0;   /* Slate 200 */
    --text-main: #334155;      /* Slate 700 */
    --text-muted: #64748b;     /* Slate 500 */
    --text-heading: #1e293b;   /* Slate 800 */
    
    /* Tipografías */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Space Grotesk', var(--font-sans);
    --font-mono: 'JetBrains Mono', monospace;

    /* Sombras y Radios */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    /* Transiciones */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 2. Reseteo y Estilos Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Tipografía de Encabezados */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-heading);
    font-weight: 600;
}

/* Utilidades de Fuente Mono */
.font-mono {
    font-family: var(--font-mono) !important;
}

/* --- 3. Layout de la Pantalla de Login (Estilo Premium Solar) --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgb(15, 23, 42) 0%, rgb(30, 41, 59) 90%);
    padding: 20px;
}

.login-container {
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

.login-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(245, 158, 11, 0.1);
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.login-title {
    font-size: 28px;
    letter-spacing: -0.05em;
    font-weight: 700;
    color: var(--primary-dark);
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Formularios de Login */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.form-control {
    width: 100%;
    padding: 12px 14px 12px 42px;
    font-size: 14px;
    font-family: var(--font-sans);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-heading);
    background-color: #fff;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* Botones */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.w-full {
    width: 100%;
}

.login-footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-muted);
}

.text-xs {
    font-size: 11px;
}

.text-orange {
    color: var(--accent-orange);
}

/* Alertas de Feedback */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.alert-danger {
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    color: #ef4444;
}

.alert-warning {
    background-color: #fffbeb;
    border: 1px solid #fef3c7;
    color: #d97706;
}

.alert-success {
    background-color: #f0fdf4;
    border: 1px solid #dcfce7;
    color: #10b981;
}

.hidden {
    display: none !important;
}

/* --- 4. Estilos del Dashboard y Header --- */

/* App Header */
.app-header {
    background-color: var(--primary-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(245, 158, 11, 0.15);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.logo-highlight {
    color: var(--accent-gold);
}

.logo-sub {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Navegación del Header */
.main-nav {
    display: flex;
    gap: 8px;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-item:hover:not(.disabled) {
    color: #fff;
    background-color: var(--primary-light);
}

.nav-item.active {
    color: #fff;
    background-color: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Menú de Usuario */
.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #f8fafc;
}

.user-role {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--accent-gold);
    letter-spacing: 0.05em;
}

.btn-logout {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ef4444;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.15);
    transform: scale(1.05);
}

/* Área Principal */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 24px;
    min-height: calc(100vh - 140px);
}

/* Barra de Encabezado de la Planta */
.dashboard-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-title {
    font-size: 24px;
    color: var(--primary-dark);
}

.section-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.status-badge {
    background-color: #f1f5f9;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    animation: pulse 1.5s infinite;
}

/* --- 5. GRID DE TARJETAS KPI (Cuadrícula Flexible) --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
}

.kpi-icon i {
    width: 24px;
    height: 24px;
}

/* Iconos Colores */
.icon-bg-yellow { background-color: rgba(245, 158, 11, 0.1); color: var(--accent-gold); }
.icon-bg-blue { background-color: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.icon-bg-red { background-color: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.icon-bg-green { background-color: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.icon-bg-orange { background-color: rgba(249, 115, 22, 0.1); color: var(--accent-orange); }
.icon-bg-purple { background-color: rgba(139, 92, 246, 0.1); color: var(--accent-purple); }
.icon-bg-teal { background-color: rgba(13, 148, 136, 0.1); color: var(--accent-teal); }
.icon-bg-slate { background-color: rgba(100, 116, 139, 0.1); color: var(--text-muted); }

.kpi-content {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    margin: 4px 0;
}

.kpi-value .unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-trend {
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Colores de Textos para KPI */
.text-amber { color: var(--accent-gold); }
.text-blue { color: var(--accent-blue); }
.text-red { color: var(--accent-red); }
.text-emerald { color: var(--accent-green); }
.text-purple { color: var(--accent-purple); }
.text-teal { color: var(--accent-teal); }

/* --- 6. BENTO GRID FINANCE (Análisis ROI y Financiero) --- */
.bento-grid-finance {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.finance-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.finance-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    width: 20px;
    height: 20px;
}

.badge {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}

/* Estructura Interna ROI */
.roi-analysis-layout {
    display: flex;
    gap: 40px;
    align-items: center;
}

.roi-circle-container {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.5s ease;
}

.roi-circle-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.roi-pct {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
}

.roi-lbl {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

.roi-details-section {
    flex-grow: 1;
}

.financial-metrics-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 6px;
}

.metric-row .lbl {
    color: var(--text-muted);
}

.metric-row .val {
    font-weight: 600;
}

.metric-row.highlight {
    border-bottom: none;
    background-color: rgba(249, 115, 22, 0.05);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

/* Tarjetas Secundarias Mini KPI */
.invoice-summary-kpis {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    justify-content: space-around;
}

.mini-kpi {
    display: flex;
    flex-direction: column;
    border-left: 3px solid var(--border-color);
    padding-left: 12px;
}

.mini-kpi:nth-child(1) { border-left-color: var(--accent-red); }
.mini-kpi:nth-child(2) { border-left-color: var(--accent-blue); }
.mini-kpi:nth-child(3) { border-left-color: var(--accent-green); }

.mini-lbl {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.mini-val {
    font-size: 16px;
    font-weight: 700;
    margin: 2px 0;
}

.mini-sub {
    font-size: 10px;
    color: var(--text-muted);
}

/* --- 7. SECCIÓN DE GRÁFICOS --- */
.dashboard-charts-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.chart-container-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.chart-container-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.chart-legend {
    display: flex;
    gap: 12px;
}

.legend-item {
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.bg-yellow { background-color: var(--accent-gold); }
.bg-blue { background-color: var(--accent-blue); }
.bg-red { background-color: var(--accent-red); }
.bg-green { background-color: var(--accent-green); }

.chart-wrapper {
    position: relative;
    height: 320px;
    width: 100%;
}

.chart-side-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chart-wrapper-small {
    position: relative;
    height: 180px;
    width: 100%;
}

/* --- 8. Pie de Página --- */
.app-footer {
    border-top: 1px solid var(--border-color);
    background-color: #fff;
    padding: 20px 24px;
    margin-top: 40px;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- 9. Animaciones --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.animate-spin-slow {
    animation: spin 16s linear infinite;
}

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

/* Icon Gold Class */
.icon-gold {
    color: var(--accent-gold);
}

.icon-lg {
    width: 32px !important;
    height: 32px !important;
}

/* --- 10. Consultas de Medios (Responsividad Absoluta) --- */
@media (max-width: 1100px) {
    .bento-grid-finance {
        grid-template-columns: 1fr;
    }
    
    .dashboard-charts-layout {
        grid-template-columns: 1fr;
    }

    .chart-side-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 14px;
    }

    .app-main {
        padding: 20px 14px;
    }

    .dashboard-header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-side-grid {
        grid-template-columns: 1fr;
    }

    .roi-analysis-layout {
        flex-direction: column;
        text-align: center;
    }

    .footer-container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}
