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

:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --accent-color: #e74c3c;
    --dark-bg: #1a1a2e;
    --light-bg: #f5f7fa;
    --text-dark: #2c3e50;
    --text-light: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--light-bg);
}

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

/* Header */
.header {
    background: var(--dark-bg);
    color: var(--text-light);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--secondary-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--text-light);
    padding: 5rem 0;
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.cta-button {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Section Styling */
section {
    padding: 4rem 0;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.section-subtitle {
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

/* Map Section */
.map-section {
    background: white;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    background: var(--light-bg);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.map-container {
    height: 500px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
}

.map-legend {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.map-legend h4 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.legend-items {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

/* Questionnaire Section */
.questionnaire-section {
    background: var(--light-bg);
}

.energy-form {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 1200px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.submit-button {
    width: 100%;
    max-width: 100%;  /* Prevent overflow */
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1.2rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-sizing: border-box;  /* Include padding in width calculation */
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Marker Cluster Styling */
.marker-cluster-small {
    background-color: rgba(46, 204, 113, 0.6);
}
.marker-cluster-small div {
    background-color: rgba(46, 204, 113, 0.8);
}

.marker-cluster-medium {
    background-color: rgba(243, 156, 18, 0.6);
}
.marker-cluster-medium div {
    background-color: rgba(243, 156, 18, 0.8);
}

.marker-cluster-large {
    background-color: rgba(231, 76, 60, 0.6);
}
.marker-cluster-large div {
    background-color: rgba(231, 76, 60, 0.8);
}

.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
}
.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 50%;
    font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
    font-weight: bold;
    color: white;
}
.marker-cluster span {
    line-height: 30px;
}

/* Results Section */
.results-section {
    background: white;
}

.user-profile {
    background: var(--light-bg);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 3rem;
    box-shadow: var(--shadow);
}

.twins-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.twin-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.twin-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.similarity-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--secondary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: right 0.3s ease;
}

.twin-card.expanded .similarity-badge {
    right: 2.5rem;
}

.twin-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

.twin-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.twin-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.detail-item {
    font-size: 0.9rem;
    color: #666;
}

.detail-item strong {
    color: var(--text-dark);
}

.insights-section {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.insights-section h3 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

/* About Section */
.about-section {
    background: var(--light-bg);
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.about-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.about-card:hover {
    transform: translateY(-4px);
}

.about-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.about-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.about-card p {
    color: #666;
    line-height: 1.8;
}

/* Footer */
.footer {
    background: var(--dark-bg);
    color: var(--text-light);
    text-align: center;
    padding: 2rem 0;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

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

    .section-title {
        font-size: 1.8rem;
    }

    .stats-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .energy-form {
        padding: 1.5rem;
    }
    
    .submit-button {
        font-size: 1rem;
        padding: 1rem;
    }

    .twins-container {
        grid-template-columns: 1fr;
    }

    nav {
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.9rem;
    }
}

/* Expanding Card Styles */
.twins-container {
    position: relative;
}

.twin-card {
    cursor: pointer;
    position: relative;
    transition: grid-column 0.6s, margin-bottom 0.6s, box-shadow 0.3s;
}

.twin-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.twin-card.moving-to-top {
    order: -1;
}

.twin-card.expanded {
    grid-column: 1 / -1;
    order: -1;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.2);
    cursor: default;
    margin-bottom: 2rem;
}

.card-overlay {
    display: none;
}

.twin-card .card-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.twin-card.expanded .card-content-wrapper {
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.twin-card .card-left {
    width: 100%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), flex 0.6s cubic-bezier(0.4, 0, 0.2, 1), border 0.6s, padding 0.6s;
}

.twin-card.expanded .card-left {
    flex: 0 0 350px;
    width: 350px;
    border-right: 2px solid #e0e0e0;
    padding-right: 2rem;
}

.twin-card .card-right {
    display: none;
}

.twin-card.expanded .card-right {
    display: block;
    opacity: 0;
    flex: 1;
    min-width: 0;
    max-height: 600px;
    overflow-y: auto;
    animation: fadeInRight 0.6s ease-in-out forwards;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.close-expanded {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-size: 1.8rem;
    color: #666;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #ddd;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.twin-card.expanded .close-expanded {
    display: flex;
}

.close-expanded:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #e74c3c;
    color: #e74c3c;
    transform: scale(1.15);
}

.chart-loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-button {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

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

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-pane {
    animation: fadeIn 0.3s;
}

.tab-pane canvas {
    max-height: 450px;
    width: 100% !important;
}

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

.timeseries-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.stat-card {
    background: #ecf0f1;
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
}

.stat-card h4 {
    color: #7f8c8d;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #2c3e50;
}
