/* ===========================
   CSS Reset & Base Styles
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Dark Mode (Default) */
    --primary-green: #10B981;
    --primary-green-dark: #059669;
    --secondary-green: #34D399;
    --accent-yellow: #FBBF24;
    --accent-red: #EF4444;

    /* Status Colors */
    --status-low: #10B981;
    --status-medium: #F59E0B;
    --status-high: #EF4444;

    /* Neutrals - Dark Mode */
    --bg-dark: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-card: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.05) 100%);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Light Mode Variables */
body.light-mode {
    --bg-dark: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;
    --gradient-card: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(5, 150, 105, 0.04) 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

body.light-mode {
    background: linear-gradient(135deg, #F0FDFA 0%, #ECFDF5 50%, #F0F9FF 100%);
}

/* ===========================
   Typography
   =========================== */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: 2.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: var(--spacing-xs);
}

/* ===========================
   Layout Components
   =========================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.section {
    margin: var(--spacing-xl) 0;
    animation: fadeInUp 0.6s ease;
}

.section-title {
    margin-bottom: var(--spacing-sm);
    text-align: center;
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* ===========================
   Glass Card Effect
   =========================== */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal), background 0.3s ease, border-color 0.3s ease;
}

body.light-mode .glass-card {
    border: 1px solid rgba(16, 185, 129, 0.15);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ===========================
   Header
   =========================== */
.header {
    padding: var(--spacing-xl) 0;
    background: var(--gradient-card);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
}

.header-content>div {
    text-align: center;
    flex: 1;
}

/* Theme Toggle Button */
.theme-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon {
    font-size: 1.8rem;
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-icon {
    transform: rotate(20deg);
}

body.light-mode .header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* ===========================
   Form Elements
   =========================== */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.input-card h3 {
    color: var(--secondary-green);
    margin-bottom: var(--spacing-md);
    font-size: 1.3rem;
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {

    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

body.light-mode .input-field {
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    color: #0F172A;
}

/* Select dropdown specific styles */
select.input-field {
    cursor: pointer;
}

/* Style for select dropdown options - ensure they're visible */
select.input-field option {
    background: #FFFFFF;
    color: #1E293B;
    padding: 0.5rem;
}

body.light-mode select.input-field option {
    background: #FFFFFF;
    color: #1E293B;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/*    Buttons    */
.btn-primary,
.btn-secondary {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    display: inline-block;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.light-mode .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

body.light-mode .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
}

.btn-large {
    width: 100%;
    padding: 1.25rem;
    font-size: 1.1rem;
}

/* ===========================
   Dashboard Components
   =========================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.stat-card {
    text-align: center;
    padding: var(--spacing-lg);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: var(--spacing-xs) 0;
}

.stat-subtext {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: var(--spacing-xs);
}

.eco-status {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xl);
    font-weight: 600;
    margin-top: var(--spacing-sm);
    font-size: 1.1rem;
}

.eco-status.low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--status-low);
}

.eco-status.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--status-medium);
}

.eco-status.high {
    background: rgba(239, 68, 68, 0.2);
    color: var(--status-high);
}



/* ===========================
   Chart Container
   =========================== */
.chart-container {
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.chart-container h3 {
    margin-bottom: var(--spacing-md);
    text-align: center;
}

/* ===========================
   Breakdown Cards
   =========================== */
.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.breakdown-card {
    text-align: center;
    padding: var(--spacing-md);
}

.breakdown-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-xs);
}

.breakdown-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-xs);
}

.breakdown-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-green);
}

/* ===========================
   Gamification
   =========================== */
.gamification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
}

.game-card {
    text-align: center;
    padding: var(--spacing-lg);
}

.game-card h3 {
    margin-bottom: var(--spacing-md);
}

.game-value {
    font-size: 3rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: var(--spacing-sm) 0;
}

.motivation-text {
    color: var(--text-secondary);
    font-style: italic;
    margin-top: var(--spacing-sm);
}

.badge-display {
    margin-top: var(--spacing-md);
}

.badge-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-xs);
}

.badge-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--secondary-green);
}





/* ===========================
   Modals
   =========================== */
.modal,
.api-key-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    max-width: 500px;
    width: 90%;
    padding: var(--spacing-xl);
    margin: var(--spacing-md);
}

.modal-content h2 {
    margin-bottom: var(--spacing-md);
}

.modal-content p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.modal-content .link {
    color: var(--primary-green);
    text-decoration: none;
    display: inline-block;
    margin-bottom: var(--spacing-md);
}

.modal-content .link:hover {
    text-decoration: underline;
}

.modal-content button {
    margin-top: var(--spacing-sm);
}

.share-text {
    background: rgba(0, 0, 0, 0.3);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin: var(--spacing-md) 0;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.copy-feedback {
    text-align: center;
    color: var(--primary-green);
    font-weight: 600;
    margin-top: var(--spacing-sm);
}

/* ===========================
   Footer
   =========================== */
.footer {
    text-align: center;
    padding: var(--spacing-lg);
    margin-top: var(--spacing-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

body.light-mode .footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

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

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===========================
   Scrollbar Styling
   =========================== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-green);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-green-dark);
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .header-content {
        flex-direction: column;
    }

    .theme-toggle {
        width: 50px;
        height: 50px;
        position: absolute;
        top: var(--spacing-md);
        right: var(--spacing-md);
    }

    .theme-icon {
        font-size: 1.5rem;
    }

    .input-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 2rem;
    }

    .game-value {
        font-size: 2.5rem;
    }

    .chat-message {
        max-width: 90%;
    }
}