:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: rgba(26, 26, 37, 0.85);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #6b6b80;
    --accent-primary: #f59e0b;
    --accent-secondary: #fbbf24;
    --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #fcd34d 100%);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --ghi-color: #22c55e;
    --dni-color: #f59e0b;
    --dhi-color: #8b5cf6;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(245, 158, 11, 0.3);
    --glow: 0 0 40px rgba(245, 158, 11, 0.3);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Animation */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(245, 158, 11, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        var(--bg-primary);
}

.sun-rays {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.2) 0%, transparent 70%);
    animation: pulse-sun 4s ease-in-out infinite;
}

@keyframes pulse-sun {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 0.8;
    }

    50% {
        transform: translateX(-50%) scale(1.1);
        opacity: 1;
    }
}

/* Navigation */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1rem 2rem;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-brand:hover {
    color: var(--accent-primary);
}

.nav-title {
    font-weight: 600;
    font-size: 1.1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-badge {
    padding: 0.5rem 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Hero */
.hero {
    padding: 8rem 2rem 3rem;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

.hero-badge i {
    color: var(--accent-primary);
    margin-right: 0.5rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero h1 span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Section */
.section {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.section-header h2 i {
    color: var(--accent-primary);
}

.section-header p {
    color: var(--text-secondary);
}

/* Cities Grid */
.cities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    max-width: 1000px;
    margin: 0 auto;
}

.city-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(20px);
}

.city-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: var(--glow);
}

.city-btn.active {
    border-color: var(--accent-primary);
    background: rgba(245, 158, 11, 0.1);
}

.city-icon {
    font-size: 2rem;
}

.city-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.city-country {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Demo Container */
.demo-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .demo-container {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-header-small {
    padding: 0 0 1rem 0;
    margin-top: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1rem;
}

.panel-header-small h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--accent-light);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: var(--accent-color);
    color: white;
}

.panel-header h3 i {
    color: var(--accent-primary);
}

.panel-content {
    padding: 1.5rem;
}

/* Parameters Grid */
.params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.param-item {
    position: relative;
}

.param-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.param-item input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

.param-item input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.param-unit {
    position: absolute;
    right: 1rem;
    bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.date-input {
    margin-bottom: 1.25rem;
}

.date-input label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.date-input input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
}

.date-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.sky-toggle {
    margin-bottom: 1.5rem;
}

.sky-toggle>label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.toggle-buttons {
    display: flex;
    gap: 0.75rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.toggle-btn:hover {
    border-color: var(--accent-primary);
}

.toggle-btn.active {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.simulate-btn {
    width: 100%;
    padding: 1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: #000;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    box-shadow: var(--glow);
}

.simulate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 60px rgba(245, 158, 11, 0.4);
}

/* Sun Info Grid */
.sun-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.sun-info-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.sun-info-item.highlight {
    grid-column: span 2;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.sun-info-icon {
    font-size: 1.75rem;
}

.sun-info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sun-info-value {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-secondary);
}

/* Totals Grid */
.totals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .totals-grid {
        grid-template-columns: 1fr;
    }
}

.total-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
}

.total-icon {
    font-size: 2.5rem;
}

.total-content {
    flex: 1;
}

.total-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.total-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.total-card.ghi .total-value {
    color: var(--ghi-color);
}

.total-card.dni .total-value {
    color: var(--dni-color);
}

.total-card.dhi .total-value {
    color: var(--dhi-color);
}

.total-bar {
    margin-top: 0.5rem;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.total-bar-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.total-card.ghi .total-bar-fill {
    background: var(--ghi-color);
}

.total-card.dni .total-bar-fill {
    background: var(--dni-color);
}

.total-card.dhi .total-bar-fill {
    background: var(--dhi-color);
}

/* Chart Container */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(20px);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-item .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-item.ghi .legend-dot {
    background: var(--ghi-color);
}

.legend-item.dni .legend-dot {
    background: var(--dni-color);
}

.legend-item.dhi .legend-dot {
    background: var(--dhi-color);
}

.legend-item.gti .legend-dot {
    background: var(--gti-color);
}

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

#irradianceChart {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* Table Container */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.table-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.table-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-header h3 i {
    color: var(--accent-primary);
}

.table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
}

td {
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

td.placeholder {
    color: var(--text-muted);
    padding: 2rem;
    font-family: inherit;
}

tr.sun-up td {
    color: var(--accent-secondary);
}

tr.sun-down td {
    color: var(--text-muted);
}

.status-sun {
    font-size: 1.1rem;
}

/* Steps Grid */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(20px);
    transition: all 0.3s;
}

.step-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
}

.step-number {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: 50%;
    font-weight: 700;
    color: #000;
}

.step-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.step-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Formulas Grid */
.formulas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.formula-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(20px);
}

.formula-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    color: var(--accent-secondary);
}

/* Footer */
footer {
    padding: 3rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.footer-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.footer-content a {
    color: var(--accent-primary);
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

/* Helper Classes */
.hidden {
    display: none !important;
}

/* Mode Toggle */
.mode-toggle-container {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 9999px;
    /* Pill shape */
    padding: 0.35rem;
    gap: 0.35rem;
    width: 100%;
    max-width: 400px;
}

.mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    border-radius: 9999px;
    /* Pill shape */
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.mode-btn i {
    font-size: 1rem;
}

/* Comparison Scenarios */
.scenario-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.scenario-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

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

.scenario-a .scenario-dot {
    background: var(--scenario-a-color);
}

.scenario-b .scenario-dot {
    background: var(--scenario-b-color);
}

.scenario-c .scenario-dot {
    background: var(--scenario-c-color);
}

.params-grid.compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0;
}

.params-grid.compact .param-item label {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
}

.params-grid.compact input {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
}

/* Comparison Totals overrides */
#comparison-totals .total-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem;
}

#comparison-totals .total-icon {
    font-size: 1.2rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-tertiary);
    font-weight: bold;
    color: var(--text-primary);
    background: var(--gti-color);
    /* Fallback */
}

/* Apply specific colors for icons in comparison */
#comparison-totals .total-card:nth-child(1) .total-icon {
    background: var(--scenario-a-color);
}

#comparison-totals .total-card:nth-child(2) .total-icon {
    background: var(--scenario-b-color);
}

#comparison-totals .total-card:nth-child(3) .total-icon {
    background: var(--scenario-c-color);
}

#comparison-totals .total-value {
    font-size: 1.2rem;
}