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

:root {
    --primary-color: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

/* ========================================
   Header
   ======================================== */
.header {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

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

.header-logo {
    height: 70px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
    background: transparent;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logo-section h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.logo-section .subtitle {
    font-size: 0.95rem;
    opacity: 0.95;
    font-weight: 400;
    margin: 0;
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    text-align: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* ========================================
   Main Container
   ======================================== */
.main-container {
    display: flex;
    height: calc(100vh - 100px);
    max-width: 1600px;
    margin: 0 auto;
    gap: 1.5rem;
    padding: 1.5rem;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: 380px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(to bottom, #ffffff, #f8fafc);
}

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

.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f9ff;
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.projects-list {
    overflow-y: auto;
    padding: 1rem;
    flex: 1;
}

/* ========================================
   Project Card
   ======================================== */
.project-card {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.project-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.project-card.active {
    border-color: var(--primary-color);
    background: linear-gradient(to bottom, #f0f9ff, white);
}

.project-type-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.project-type-badge.agrivoltaico {
    background: #d1fae5;
    color: #065f46;
}

.project-type-badge.fotovoltaico {
    background: #fef3c7;
    color: #92400e;
}

.project-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    padding-right: 100px;
}

.project-location {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.project-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.info-item {
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: 8px;
}

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

.info-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.project-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0fdf4;
    border-left: 3px solid var(--secondary-color);
    border-radius: 4px;
    font-size: 0.85rem;
}

.status-icon {
    color: var(--secondary-color);
}

/* ========================================
   Map Container
   ======================================== */
.map-container {
    flex: 1;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* ========================================
   Map Legend
   ======================================== */
.map-legend {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    min-width: 220px;
}

.map-legend h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.legend-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.legend-marker.agrivoltaico {
    background: #10b981;
}

.legend-marker.fotovoltaico {
    background: #f59e0b;
}

.legend-status {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.legend-status p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.legend-status p:first-child {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* ========================================
   Leaflet Custom Styles
   ======================================== */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow-xl);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 320px;
}

.popup-header {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 0 0;
}

.popup-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.popup-location {
    font-size: 0.875rem;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.popup-body {
    padding: 1.25rem;
}

.popup-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.popup-stat {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.popup-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.popup-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-details {
    font-size: 0.875rem;
    line-height: 1.8;
}

.popup-details p {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-color);
}

.popup-details p:last-child {
    border-bottom: none;
}

.popup-details strong {
    color: var(--text-primary);
}

.popup-details span {
    color: var(--text-secondary);
    text-align: right;
}

.popup-footer {
    padding: 1rem 1.25rem;
    background: var(--bg-color);
    border-radius: 0 0 12px 12px;
    text-align: center;
}

.view-details-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.view-details-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ========================================
   Modal
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    font-weight: 300;
    color: white;
    cursor: pointer;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: rotate(90deg);
}

.modal-header {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px 16px 0 0;
}

.modal-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-body-content {
    padding: 2rem;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

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

.detail-item {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

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

.detail-item-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 400px;
    }
    
    .map-container {
        height: 600px;
    }
    
    .header-stats {
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-stats {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stat-item {
        flex: 1;
        min-width: 100px;
    }
    
    .main-container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .sidebar {
        max-height: 300px;
    }
    
    .map-container {
        height: 500px;
    }
    
    .map-legend {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .project-info {
        grid-template-columns: 1fr;
    }
    
    .popup-stats {
        grid-template-columns: 1fr;
    }
    
    .leaflet-popup-content {
        min-width: 280px;
    }
    
    .header-logo {
        height: 50px;
    }
    
    .logo-section {
        gap: 0.75rem;
    }
    
    .logo-section h1 {
        font-size: 1.3rem;
    }
    
    .logo-section .subtitle {
        font-size: 0.85rem;
    }
}

/* ========================================
   Scrollbar Styling
   ======================================== */
.projects-list::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.projects-list::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 10px;
}

.projects-list::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.projects-list::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
