/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', Arial, sans-serif;
    background-color: #fdf1eb;
    color: #333;
    line-height: 1.6;
    letter-spacing: -0.8px;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6, b {
    letter-spacing: -1.5px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    background-color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.navbar-brand .logo {
    height: 40px;
    width: auto;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-link {
    color: #1b4444;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover {
    background-color: #fcbd25;
    color: #1b4444;
}

.nav-link.active {
    background-color: #1b4444;
    color: white;
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.dropdown-icon {
    fill: currentColor;
    transition: transform 0.3s ease;
}

.dropdown-toggle.active .dropdown-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-divider {
    height: 1px;
    background-color: #e9ecef;
    margin: 8px 0;
}

/* Main content */
.main-content {
    min-height: calc(100vh - 70px);
    padding: 40px 0;
}

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 75px);
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

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

.auth-logo {
    height: 60px;
    margin-bottom: 20px;
}

.auth-title {
    color: #1b4444;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: #666;
    font-size: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    color: #1b4444;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.form-input:focus {
    outline: none;
    border-color: #fcbd25;
}

.form-input.error {
    border-color: #dc3545;
}

.form-error {
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
}

.form-success {
    color: #459f49;
    font-size: 14px;
    margin-top: 5px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-primary {
    background-color: #fcbd25;
    color: #1b4444;
}

.btn-primary:hover {
    background-color: #e6a820;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #1b4444;
    color: white;
}

.btn-secondary:hover {
    background-color: #0f2f2f;
    transform: translateY(-2px);
}

.btn-outline {
    background-color: transparent;
    color: #1b4444;
    border: 2px solid #1b4444;
}

.btn-outline:hover {
    background-color: #1b4444;
    color: white;
}

.btn-google {
    background-color: white;
    color: #333;
    border: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.btn-google:hover {
    border-color: #fcbd25;
    background-color: #fcbd25;
}

.btn-block {
    width: 100%;
    margin-bottom: 15px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Google button icon */
.google-icon {
    width: 20px;
    height: 20px;
}

/* Auth divider */
.auth-divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e9ecef;
}

.auth-divider span {
    background-color: white;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
}

/* Auth links */
.auth-links {
    text-align: center;
    margin-top: 25px;
}

.auth-link {
    color: #1b4444;
    text-decoration: none;
    font-weight: 500;
}

.auth-link:hover {
    text-decoration: underline;
}

/* Dashboard */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.dashboard-header {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.dashboard-title {
    color: #1b4444;
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 10px;
}

.dashboard-subtitle {
    color: #666;
    font-size: 18px;
}

.dashboard-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.empty-state {
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    color: #fcbd25;
    margin-bottom: 20px;
}

.empty-state-title {
    color: #1b4444;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-state-description {
    color: #666;
    font-size: 16px;
    max-width: 400px;
    margin: 0 auto;
}

/* Dashboard específico */
.loading-container {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #fcbd25;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.error-container {
    text-align: center;
    padding: 60px 20px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc3545;
}

.error-icon i {
    width: 48px;
    height: 48px;
}

.error-container h3 {
    color: #1b4444;
    font-size: 24px;
    margin-bottom: 10px;
}

.error-container p {
    color: #666;
    margin-bottom: 20px;
}

/* Historical Chart Section */
.historical-chart-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Difference Chart Section */
.difference-chart-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f8f9fa;
}

.chart-title {
    color: #1b4444;
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    width: 28px;
    height: 28px;
    color: #fcbd25;
}

.chart-controls {
    display: flex;
    gap: 8px;
    background: #f8f9fa;
    padding: 4px;
    border-radius: 8px;
}

.period-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.period-btn:hover {
    background: #e9ecef;
    color: #1b4444;
}

.period-btn.active {
    background: #fcbd25;
    color: #1b4444;
    font-weight: 600;
}

.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 20px;
}

.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.chart-loading .loading-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 15px;
}

.chart-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #dc3545;
    text-align: center;
}

.chart-error i {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
}

.chart-error p {
    margin-bottom: 15px;
    color: #666;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

#historicalChart {
    width: 100% !important;
    height: 100% !important;
}

#differenceChart {
    width: 100% !important;
    height: 100% !important;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

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

.legend-color {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.legend-item.consumption .legend-color {
    background-color: #1b4444;
}

.legend-item.generation .legend-color {
    background-color: #459f49;
}

.legend-item.surplus .legend-color {
    background-color: #dc3545;
}

.legend-item.deficit .legend-color {
    background-color: #459f49;
}

.legend-item.solar .legend-color {
    background-color: #fcbd25;
}

.legend-item.grid .legend-color {
    background-color: #6b7280;
}

.legend-label {
    color: #333;
}

/* Dashboard stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    font-size: 32px;
    color: #fcbd25;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    width: 32px;
    height: 32px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
    color: #1b4444;
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

.stat-description {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
    font-style: italic;
    line-height: 1.2;
}

/* Generators list */
.generators-list {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.generator-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

.generator-card.no-participation {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    opacity: 0.8;
}

.generator-card.no-participation .generator-title {
    color: #6c757d;
}

.generator-card.no-participation .generator-participation {
    background: #e9ecef;
    color: #6c757d;
}

.generator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f8f9fa;
}

.generator-title {
    color: #1b4444;
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.generator-participation {
    background: #fcbd25;
    color: #1b4444;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 16px;
}

.generator-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    align-items: center;
}

.metric-gauge {
    text-align: center;
}

.gauge-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto 15px;
}

.gauge-canvas {
    width: 100% !important;
    height: 100% !important;
}

.gauge-value {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 600;
    color: #1b4444;
    text-align: center;
    line-height: 1.2;
}

.gauge-label {
    font-size: 16px;
    font-weight: 500;
    color: #1b4444;
    margin-bottom: 5px;
}

.gauge-unit {
    font-size: 12px;
    color: #666;
}

.no-data {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.last-update {
    text-align: center;
    color: #666;
    font-size: 12px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .generator-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .generator-metrics {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .gauge-container {
        width: 120px;
        height: 120px;
    }
    
    .gauge-value {
        font-size: 14px;
    }
    
    /* Historical chart responsive */
    .historical-chart-section {
        padding: 20px;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .chart-title {
        font-size: 20px;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .chart-legend {
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .generator-card {
        padding: 20px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-icon {
        font-size: 24px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .generator-title {
        font-size: 20px;
    }
    
    .gauge-container {
        width: 100px;
        height: 100px;
    }
    
    .gauge-value {
        font-size: 12px;
    }
}

/* CUPS assignment */
.cups-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.cups-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
    position: relative;
}

/* Logout button for CUPS assignment page */
.logout-container {
    position: absolute;
    top: 20px;
    right: 20px;
}

.logout-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.logout-btn:hover {
    background: #fcbd25;
    border-color: #fcbd25;
    transform: translateY(-2px);
}

.logout-btn i {
    width: 20px;
    height: 20px;
    color: #666;
    transition: color 0.3s ease;
}

.logout-btn:hover i {
    color: #1b4444;
}

.cups-icon {
    font-size: 48px;
    color: #fcbd25;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cups-icon .lucide-icon {
    width: 48px;
    height: 48px;
}

.cups-title {
    color: #1b4444;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 15px;
}

.cups-description {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.cups-form {
    text-align: left;
}

.cups-input {
    font-size: 18px;
    padding: 15px 20px;
    text-align: center;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1b4444;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-hidden {
    display: none !important;
}

/* Form visibility states */
.form-visible {
    display: block !important;
}

.form-hidden {
    display: none !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.footer {
    background-color: #1b4444;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: auto;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-hidden {
    display: none !important;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    color: #1b4444;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

.modal-buttons .btn {
    margin-bottom: 0;
    min-width: 120px;
}

.close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.form-help {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

/* Profile message styles */
.profile-message {
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid;
    animation: slideDown 0.3s ease-out;
}

.profile-message.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.profile-message.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.message-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.message-text {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .navbar .container {
        padding: 10px 15px;
    }
    
    .navbar-nav {
        gap: 15px;
    }
    
    .auth-card {
        padding: 30px 20px;
        margin: 10px;
    }
    
    .auth-title {
        font-size: 24px;
    }
    
    .dashboard-header {
        padding: 20px;
    }
    
    .dashboard-title {
        font-size: 28px;
    }
    
    .dashboard-content {
        padding: 30px 20px;
    }
    
    .cups-card {
        padding: 30px 20px;
        margin: 10px;
    }
    
    .cups-title {
        font-size: 24px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .navbar-brand .logo {
        height: 35px;
    }
    
    .nav-link {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .auth-card {
        padding: 25px 15px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .form-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .modal-content {
        width: 98%;
        margin: 5px;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
}

/* Plugs chart section */
.plugs-chart-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#plugsChart {
    width: 100% !important;
    height: 100% !important;
}

.legend-item.plugs .legend-color {
    background-color: #1e40af;
}

.legend-item.other .legend-color {
    background-color: #6b7280;
}

/* Responsive adjustments for plugs chart */
@media (max-width: 768px) {
    .plugs-chart-section {
        padding: 20px;
    }
}
