/* Base Variables for Light/Dark */

:root {
    --bg-color: #f9f9f9;
    --text-color: #333;
    --card-bg: #fff;
    --border-color: #ddd;
    --primary-color: #36d1dc;
    --secondary-color: #5b86e5;
    --tooltip-bg: #333;
    --tooltip-text: #fff;
    font-family: 'Inter', sans-serif;
    color-scheme: light;
}

 :root[data-theme='dark'] {
    --bg-color: #121212;
    --text-color: #ddd;
    --card-bg: #1e1e1e;
    --border-color: #333;
    --primary-color: #36d1dc;
    --secondary-color: #5b86e5;
    --tooltip-bg: #eee;
    --tooltip-text: #333;
    color-scheme: dark;
}

 :root[data-theme='pastel'] {
    --bg-color: #fefafc;
    --text-color: #333;
    --card-bg: #ffffffcc;
    --border-color: #ddd;
    --primary-color: #f5a9b8;
    --secondary-color: #c8a2c8;
    --tooltip-bg: #333;
    --tooltip-text: #fff;
}

 :root[data-theme='high-contrast'] {
    --bg-color: #ffffff;
    --text-color: #000;
    --card-bg: #ffffff;
    --border-color: #000;
    --primary-color: #0000ff;
    --secondary-color: #ff00ff;
    --tooltip-bg: #000;
    --tooltip-text: #fff;
}


/* Global Reset & Base */

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
h4,
p,
label,
button,
input,
select,
option,
small {
    font-family: inherit;
    color: var(--text-color);
}

header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: #fff;
    position: relative;
}

header h1 {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

header p {
    margin: 0;
    font-size: 1.1rem;
}

.top-controls {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.top-controls label,
.top-controls button {
    font-size: 0.9rem;
    color: #fff;
}

main {
    display: flex;
    flex-wrap: wrap;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    gap: 2rem;
    position: relative;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ccc;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.input-section,
.output-section {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
}

.input-section {
    flex: 1 1 350px;
    max-width: 400px;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.4rem;
    position: relative;
}

.input-group label {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    background: var(--bg-color);
    color: var(--text-color);
    transition: box-shadow 0.3s ease, transform 0.1s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(54, 209, 220, 0.5);
    transform: scale(1.01);
}

.error-msg {
    color: red;
    font-size: 0.8rem;
    height: 1rem;
}

.shake {
    animation: shakeAnim 0.3s;
}

@keyframes shakeAnim {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-3px);
    }
    50% {
        transform: translateX(3px);
    }
    75% {
        transform: translateX(-3px);
    }
    100% {
        transform: translateX(0);
    }
}

.scenario-toggle {
    margin-bottom: 1.2rem;
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

h2,
h3,
h4 {
    margin-top: 0;
}

.actions {
    text-align: center;
    margin-top: 1.5rem;
}

.main-actions {
    margin-top: 1rem;
}

#calculate-btn,
#save-scenario-btn,
#load-scenario-btn,
#compare-scenarios-btn,
#run-compare-btn,
#close-compare-btn,
#start-tour-btn {
    padding: 0.8rem 1.5rem;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border: none;
    border-radius: 4px;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.1s ease;
    margin: 0.2rem;
}

button:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.disclaimer {
    font-size: 0.8rem;
    margin-top: 1rem;
    color: #666;
    font-style: italic;
}

.output-section {
    flex: 3 1 600px;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.fade-in {
    opacity: 0;
    animation: fadeInAnim 1s forwards ease-in;
}

@keyframes fadeInAnim {
    to {
        opacity: 1;
    }
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tab-button {
    background: var(--border-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

.tab-button.active {
    background: var(--primary-color);
    color: #fff;
}

.tab-button:hover {
    background: var(--primary-color);
    color: #fff;
}

.tab-content.hidden {
    display: none;
}

.results {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    margin-top: 2rem;
    gap: 1rem;
}

.result-item {
    margin: 0.5rem 1rem;
    font-size: 1rem;
}

.result-item span {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.sustainability {
    text-align: center;
    margin-top: 2rem;
}

.gauge-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.gauge {
    width: 120px;
    height: 120px;
    background: none;
    border-radius: 50%;
    position: relative;
}

.gauge .gauge-fill {
    width: 100%;
    height: 100%;
    background: conic-gradient(var(--primary-color) 0deg, #ccc 0deg);
    border-radius: 50%;
    transform: rotate(-90deg);
    transition: transform 0.5s ease, background 0.5s ease;
}

.gauge .gauge-cover {
    width: 70%;
    height: 70%;
    background: var(--card-bg);
    border-radius: 50%;
    position: absolute;
    top: 15%;
    left: 15%;
}

.distribution-section {
    text-align: center;
    margin-top: 2rem;
}

.tooltip {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    text-align: center;
    line-height: 18px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 4px;
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    width: 200px;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    display: none;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tooltip:hover::after {
    display: block;
    opacity: 1;
}

.heart {
    color: #e25555;
}

.collapse-btn {
    font-size: 0.8rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
}

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

.hidden {
    display: none !important;
}

.tour-overlay,
.compare-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tour-step,
.compare-content {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    max-width: 300px;
    text-align: center;
}

.compare-results {
    margin-top: 1rem;
}

.controls-below-tabs {
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width:900px) {
    main {
        flex-direction: column;
    }
    .top-controls {
        position: static;
        margin: 0 auto 1rem auto;
        flex-direction: column;
    }
    .output-section,
    .input-section {
        width: 100%;
        max-width: 100%;
    }
}