/* Premium Dark-Mode Glassmorphic CSS System for PV Forecast Service */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-main: #060913;
    --bg-card: rgba(15, 23, 42, 0.6);
    --bg-card-hover: rgba(30, 41, 59, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(99, 102, 241, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-indigo: #6366f1;
    --accent-violet: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    /* Gradients */
    --grad-primary: linear-gradient(135deg, var(--accent-indigo) 0%, var(--accent-violet) 100%);
    --grad-cyan-blue: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
    --grad-dark: linear-gradient(180deg, #0f172a 0%, #060913 100%);
    --grad-text: linear-gradient(90deg, #f8fafc 0%, #cbd5e1 100%);
    --grad-glow: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);

    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    --shadow-glow-cyan: 0 0 25px rgba(6, 182, 212, 0.25);
}

/* Global resets & styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0, transparent 50%),
        radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.95) 0, var(--bg-main) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbar configuration */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.6);
}

.page {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}
.page.active {
    display: block;
}

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

/* Glass panel utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-main);
}

/* Login Page */
#login-page {
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#login-page.active {
    display: flex;
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.login-container h1 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    text-align: center;
}

.login-container p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 32px;
    text-align: center;
}

.register-link {
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-muted);
}

.register-link a {
    color: var(--accent-indigo);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.register-link a:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

/* Header & Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    height: 72px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #ffffff 0%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a.active {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-display {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Forms styling */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-indigo);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Buttons styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 8px;
}

.btn-primary {
    background: var(--grad-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.45);
    opacity: 0.95;
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}
.btn-secondary:active {
    transform: translateY(0);
}

.btn-info {
    background: var(--grad-cyan-blue);
    color: white;
    box-shadow: var(--shadow-glow-cyan);
}
.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.45);
    opacity: 0.95;
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
}

.btn-tiny {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-tiny:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Sections */
.section {
    display: none;
    padding: 40px 24px;
    max-width: 1280px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease-out forwards;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Projects grid and cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.card {
    position: relative;
    padding: 28px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.03) 0%, rgba(6, 182, 212, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.card:hover {
    transform: translateY(-6px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.1);
    background-color: var(--bg-card-hover);
}

.card:hover::before {
    opacity: 1;
}

.card h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 16px;
}

.form-card, .detail-card {
    padding: 32px;
    margin-bottom: 24px;
}

/* Detail info grid layout */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.detail-card h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 12px;
}

.detail-info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 14px;
}

.detail-info-row strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-info-row span {
    color: var(--text-primary);
}

/* API Key */
.api-key-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.api-key-display code {
    background: rgba(15, 23, 42, 0.6);
    padding: 12px 16px;
    border-radius: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: var(--accent-cyan);
    border: 1px solid var(--border-color);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 16px;
}

.data-table th, .data-table td {
    padding: 14px 16px;
    text-align: left;
}

.data-table th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 14px;
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-error {
    background: rgba(239, 68, 110, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 110, 0.25);
}

.badge-info {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
    border: 1px solid rgba(6, 182, 212, 0.25);
}

/* Forecast summary grids */
.forecast-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 16px;
}

.summary-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s;
}
.summary-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(99, 102, 241, 0.2);
}

.summary-item .value {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.summary-item .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Charts and Visualization */
.chart-container {
    margin-top: 24px;
    padding: 24px;
    text-align: center;
}

.forecast-chart {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.chart-placeholder {
    padding: 60px;
    color: var(--text-muted);
}

/* Alerts */
.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-main);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid var(--success);
}
.toast-success span::before {
    content: '✓ ';
    color: var(--success);
    font-weight: bold;
}

.toast-error {
    border-left: 4px solid var(--danger);
}
.toast-error span::before {
    content: '✕ ';
    color: var(--danger);
    font-weight: bold;
}

.toast-warning {
    border-left: 4px solid var(--warning);
}
.toast-warning span::before {
    content: '⚠ ';
    color: var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}
.toast-info span::before {
    content: 'ℹ ';
    color: var(--info);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    transition: color 0.2s;
}
.toast-close:hover {
    color: var(--text-primary);
}

.project-id {
    background: rgba(15, 23, 42, 0.8);
    padding: 6px 12px;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: var(--accent-cyan);
    border: 1px solid var(--border-color);
}

/* Modals Overlay & Content */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 7, 18, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 24px 48px rgba(0,0,0,0.8);
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}
.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body pre {
    background: rgba(10, 15, 30, 0.8);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #a5b4fc;
    overflow-x: auto;
    max-height: 450px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.2);
}

/* Guide box (Sample Configurations Guide) */
.guide-box {
    margin-top: 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.15);
    padding: 24px;
    border-radius: 12px;
}
.guide-box h4 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 12px;
}
.guide-box p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.guide-box ul {
    margin-left: 20px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}
.guide-box li {
    margin-bottom: 6px;
}

/* Quick Seeding Banner */
.seeding-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--grad-glow);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.seeding-text h4 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.seeding-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Code block snippet views in docs */
pre code {
    display: block;
    padding: 16px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #cbd5e1;
    overflow-x: auto;
}

/* Responsive adjustment */
@media (max-width: 992px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 20px;
        flex-direction: column;
        height: auto;
        padding-top: 16px;
        padding-bottom: 16px;
        gap: 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .forecast-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}
