/**
 * Global Map Controls CSS
 * Styles for map-related buttons and controls used across the application
 * Includes: polygon controls, distance calculator, surface calculator, etc.
 */

/* Additional polygon, clear, delete selected, and toggle drag buttons - bigger with light background */
.additional-polygon-btn,
.clear-polygons-btn,
.delete-selected-btn,
.toggle-drag-btn {
    width: 40px !important;
    height: 40px !important;
    border: none !important;
    background: #f0f9ff !important; /* Light blue background */
    color: #0369a1 !important;
    font-size: 18px !important; /* Bigger icon */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px !important;
    transition: background 0.2s ease, color 0.2s ease, transform 0.05s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.additional-polygon-btn:hover,
.clear-polygons-btn:hover,
.delete-selected-btn:hover,
.toggle-drag-btn:hover {
    background: #e0f2fe !important; /* Lighter blue on hover */
    color: #075985 !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.additional-polygon-btn:active,
.clear-polygons-btn:active,
.delete-selected-btn:active,
.toggle-drag-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.clear-polygons-btn {
    background: #fef2f2 !important; /* Light red background */
    color: #991b1b !important;
}

.clear-polygons-btn:hover {
    background: #fee2e2 !important; /* Lighter red on hover */
    color: #7f1d1d !important;
}

.delete-selected-btn {
    background: #fef2f2 !important; /* Light red background */
    color: #991b1b !important;
}

.delete-selected-btn:hover {
    background: #fee2e2 !important; /* Lighter red on hover */
    color: #7f1d1d !important;
}

.toggle-drag-btn {
    background: #f0fdf4 !important; /* Light green background */
    color: #166534 !important;
}

.toggle-drag-btn:hover {
    background: #dcfce7 !important; /* Lighter green on hover */
    color: #14532d !important;
}

.toggle-drag-btn.active {
    background: #22c55e !important; /* Green when active */
    color: #ffffff !important;
}

.toggle-drag-btn.active:hover {
    background: #16a34a !important; /* Darker green on hover when active */
    color: #ffffff !important;
}

/* Path Distance Button - Global styles (Orange) */
.path-distance-btn {
    width: 40px !important;
    height: 40px !important;
    border: none !important;
    background: #fed7aa !important; /* Light orange background */
    color: #c2410c !important;
    font-size: 18px !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px !important;
    transition: background 0.2s ease, color 0.2s ease, transform 0.05s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.path-distance-btn:hover {
    background: #fdba74 !important;
    color: #9a3412 !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.path-distance-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.path-distance-btn.active {
    background: #f97316 !important; /* Orange when active */
    color: white !important;
}

/* Surface Calculator Button - Global styles */
.surface-calculator-btn {
    width: 40px !important;
    height: 40px !important;
    border: none !important;
    background: #fed7aa !important; /* Light orange background */
    color: #c2410c !important;
    font-size: 18px !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px !important;
    transition: background 0.2s ease, color 0.2s ease, transform 0.05s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.surface-calculator-btn:hover {
    background: #fdba74 !important;
    color: #9a3412 !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.surface-calculator-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.surface-calculator-btn.active {
    background: #f97316 !important; /* Orange when active */
    color: white !important;
}

/* Polygon context menu */
#polygon-context-menu {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

#polygon-context-menu > div {
    transition: background-color 0.15s ease;
}

#polygon-context-menu > div:hover {
    background-color: #f3f4f6;
}

/* Leaflet control button containers */
.leaflet-control-additional-polygon,
.leaflet-control-delete-selected,
.leaflet-control-toggle-drag,
.leaflet-control-path-distance,
.leaflet-control-surface-calculator {
    margin: 10px 10px 0 0;
}

.leaflet-control-additional-polygon .leaflet-bar,
.leaflet-control-delete-selected .leaflet-bar,
.leaflet-control-toggle-drag .leaflet-bar,
.leaflet-control-path-distance .leaflet-bar,
.leaflet-control-surface-calculator .leaflet-bar {
    border: none;
    box-shadow: none;
    background: transparent;
}

/* Ensure buttons are properly displayed in Leaflet controls */
.additional-polygon-control-container,
.delete-selected-control-container,
.toggle-drag-control-container,
.path-distance-control-container,
.surface-calculator-control-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* ===== PLANT POPUP STYLES ===== */
/* Shared styles for plant popups used across all map pages (plants, assign, registrations) */
.plant-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    line-height: 1.3;
    color: #1f2937;
    min-width: 200px;
    max-width: 280px;
}

.plant-popup-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
}

.plant-popup-title i {
    color: #10b981;
    font-size: 12px;
}

.leaflet-popup-content p.plant-popup-field {
    margin: 2px 0 2px 0;
    font-size: 11px;
    line-height: 1.3;
}

.plant-popup-field strong {
    color: #374151;
    font-weight: 600;
    margin-right: 4px;
    font-size: 11px;
}

.plant-popup-services-list {
    margin: 4px 0;
    padding-left: 16px;
    font-size: 10px;
    line-height: 1.4;
}

.plant-popup-services-list li {
    margin: 2px 0;
}

.plant-popup-actions {
    margin-top: 12px;
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.leaflet-popup-content .plant-popup-view-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.leaflet-popup-content .plant-popup-view-btn:hover {
    background: #2563eb;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.plant-popup-view-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.plant-popup-view-btn i {
    margin-right: 4px;
    font-size: 11px;
}

/* Characteristics content: clamp height with subtle fade-out */
.plant-popup-characteristics-content .characteristics-content {
    max-height: 90px;
    overflow: hidden;
    position: relative;
}

.plant-popup-characteristics-content .characteristics-content::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 70px;
    height: 20px;
    /* Fade from transparent to solid popup background */
    background: linear-gradient(to bottom, rgba(249, 250, 251, 0), rgba(249, 250, 251, 1));
    pointer-events: none;
}

