/* Base map styling */
#map {
    width: 100%;
    height: 700px;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Custom Marker Styles */
.custom-marker {
    position: relative;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

.marker-inner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.greenhouse-marker .marker-inner {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.company-marker .marker-inner {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.marker-pulse {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    animation: pulse 2s infinite;
    opacity: 0.6;
}

.greenhouse-marker .marker-pulse {
    background: #10b981;
}

.company-marker .marker-pulse {
    background: #3b82f6;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.custom-marker:hover .marker-inner,
.marker-hover .marker-inner {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Modern Popup Styles */
.leaflet-popup-content-wrapper {
    background: white !important;
    border-radius: 16px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.leaflet-popup-tip {
    background: white !important;
    border: 1px solid #e2e8f0 !important;
}

.modern-popup {
    padding: 20px;
    max-width: 280px;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.popup-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.popup-icon.greenhouse {
    background: linear-gradient(135deg, #10b981, #059669);
}

.popup-icon.company {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.popup-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.popup-type {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.popup-content {
    margin-bottom: 16px;
}

.popup-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #475569;
}

.popup-info:last-child {
    margin-bottom: 0;
}

.info-icon {
    width: 16px;
    height: 16px;
    color: #94a3b8;
    flex-shrink: 0;
}

.popup-actions {
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.popup-button {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    justify-content: center;
}

.popup-button:hover {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Details Panel Styles */
.marker-details-modern {
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.details-header {
    margin-bottom: 24px;
}

.details-image {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.details-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.image-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
}

.marker-type-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.marker-type-badge.greenhouse {
    background: linear-gradient(135deg, #10b981, #059669);
}

.marker-type-badge.company {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.details-title h4 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.info-section {
    margin-bottom: 24px;
}

.info-section h5 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #334155;
}

.info-grid {
    display: grid;
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.info-item .info-icon {
    width: 20px;
    height: 20px;
    color: #64748b;
    flex-shrink: 0;
}

.info-label {
    font-weight: 500;
    color: #64748b;
    min-width: 60px;
}

.info-value {
    color: #1e293b;
    font-weight: 500;
}

.divider {
    height: 1px;
    background: #e2e8f0;
    margin: 24px 0;
}

.automation-info {
    padding: 16px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}

.automation-info p {
    margin: 0 0 8px 0;
    color: #475569;
    font-weight: 500;
}

.automation-info p:last-child {
    margin-bottom: 0;
}

.automation-info a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.automation-info a:hover {
    text-decoration: underline;
}

.environmental-grid {
    display: grid;
    gap: 16px;
    padding-bottom: 50px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.env-card {
    padding: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.env-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #334155;
}

.env-icon {
    width: 20px;
    height: 20px;
    color: #64748b;
}

.env-values {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.env-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.env-label {
    font-size: 14px;
    color: #64748b;
}

.env-value {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

/* Legacy popup support (fallback) */
.custom-popup {
    direction: rtl;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.custom-popup h3 {
    font-size: 16px;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
    margin-bottom: 12px;
    font-weight: 600;
}

.custom-popup p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #64748b;
}

/* Enhanced zoom controls */
.leaflet-control-zoom {
    border: none !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.5) !important;
    border-radius: 12px !important;
    margin: 4px 0;
    font-weight: bold;
    font-size: 18px !important;
    color: #334155 !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background: rgba(255, 255, 255, 1) !important;
    color: #10b981 !important;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.leaflet-control-zoom-in:active,
.leaflet-control-zoom-out:active {
    transform: scale(0.95);
}

/* Attribution control */
.leaflet-control-attribution.leaflet-control {
    display: none;
}

/* Map tile styling */
.leaflet-tile {
    filter: contrast(1.1) saturate(0.9);
}

/* Map container enhancements */
#map {
    transition: all 0.3s ease;
}

#map.high-zoom .leaflet-marker-icon {
    transform: scale(1.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #map {
        height: 500px;
        border-radius: 12px;
    }

    .leaflet-control-zoom-in,
    .leaflet-control-zoom-out {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
    }

    .modern-popup {
        padding: 16px;
        max-width: 260px;
    }

    .marker-details-modern {
        padding: 16px;
    }

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

    .info-grid {
        gap: 8px;
    }

    .info-item {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    #map {
        height: 400px;
        border-radius: 8px;
    }

    .leaflet-popup-content-wrapper {
        border-radius: 12px !important;
    }

    .leaflet-control-zoom-in,
    .leaflet-control-zoom-out {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }
}
