:root {
    --primary-color: rgb(115, 176, 118);
    --primary-hover: rgb(48, 119, 37);
    --bg-dark: #001e2e;
    --panel-bg: rgba(0, 30, 46, 0.95);
    --text-main: rgb(215, 234, 216);
    --text-dim: rgb(151, 197, 212);
    --border-color: rgba(151, 197, 212, 0.4);
    --accent-glow: 0 0 15px rgba(115, 176, 118, 0.4);
    --danger-color: rgb(238, 2, 45);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
}

#map {
    flex-grow: 1;
    height: 100%;
    z-index: 1;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    height: 100%;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px;
}

.section {
    margin-bottom: 15px;
}

.section h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

/* Control Elements */
.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 4px;
    color: var(--text-main);
}

.input-styled {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.input-styled option {
    background: #1e1e1e;
    color: white;
}

/* Compact number inputs */
.input-number {
    width: 80px !important;
}

.input-styled:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--accent-glow);
}

.btn-primary {
    width: 100%;
    background: var(--primary-color);
    color: #000;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    width: 100%;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 5px;
}

.btn-secondary:hover {
    background: rgba(115, 176, 118, 0.1);
}

/* Variant Switcher */
.variant-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.variant-tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.variant-tab.active {
    background: var(--primary-color);
    color: #000;
    font-weight: 600;
}

/* Legend */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* WEA Labels */
.wea-label {
    background: var(--panel-bg) !important;
    backdrop-filter: blur(4px);
    border: 1px solid var(--primary-color) !important;
    color: white !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    padding: 4px 8px !important;
}

.wea-label::before {
    border-right-color: var(--primary-color) !important;
}

/* UI States */
.btn-secondary.active {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* Disable interaction with other layers during turbine placement to allow clicking 'through' them */
#map.placement-active .leaflet-interactive:not(.turbine-icon-container, .turbine-icon-container *) {
    pointer-events: none !important;
}

/* Floating Panels General */
.floating-panel {
    position: absolute;
    z-index: 1000;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
}

.panel-content {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

/* Floating Legend Specific */
#floatingLegend {
    bottom: 20px;
    right: 20px;
    width: 220px;
}

#floatingLegend.collapsed .panel-content {
    display: none;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.collapsed .toggle-btn {
    transform: rotate(180deg);
}

/* Floating Edit Panel Tweak */
#editPanel {
    position: absolute;
    z-index: 2000;
    display: none;
}

.edit-panel-content {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 10px;
    width: 210px;
    /* Slimmer */
    max-height: 85vh;
    /* DON'T CUT OFF */
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5), var(--accent-glow);
}

.edit-rows-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 2px;
}

.edit-row.separator {
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
}

.edit-row label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin: 0;
    white-space: nowrap;
    width: 65px;
    text-align: left;
}

.edit-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
    text-align: left;
    width: 100px;
}

.btn-primary-mini {
    background: var(--primary-color);
    color: #000;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-danger-mini {
    background: rgba(238, 2, 45, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

.leaflet-control-layers {
    background: var(--panel-bg) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color) !important;
    color: white !important;
    border-radius: 12px !important;
    padding: 10px !important;
}

/* Proximity Tooltips - Compact & Integrated */
.proximity-tooltip {
    background: rgba(255, 136, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: #000 !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    border-radius: 3px !important;
    padding: 1px 4px !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

.proximity-tooltip::before {
    display: none !important;
}

.proximity-tooltip-red {
    background: rgba(220, 0, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    border-radius: 3px !important;
    padding: 1px 4px !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

.proximity-tooltip-red::before {
    display: none !important;
}

.proximity-tooltip-yellow {
    background: rgba(204, 180, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: #000 !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    border-radius: 3px !important;
    padding: 1px 4px !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

.proximity-tooltip-yellow::before {
    display: none !important;
}

.proximity-tooltip-violet {
    background: rgba(148, 0, 211, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
    border-radius: 3px !important;
    padding: 1px 4px !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

.proximity-tooltip-violet::before {
    display: none !important;
}

/* Custom Turbine Symbol (Professional SVG) */
.turbine-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: transform 0.2s ease;
}

.turbine-icon-container svg {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
    width: 100%;
    height: 100%;
}

.turbine-icon-container:hover {
    transform: scale(1.15);
    cursor: grab;
}

.turbine-icon-container:active {
    cursor: grabbing;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 800px;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    /* Contain children and scrollbars */
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: white;
}

/* Owner Table & Mapping Scrollability */
#ownerListSection {
    display: none;
    /* Controlled by JS */
    flex-direction: column;
    overflow: hidden;
    flex-grow: 1;
    min-height: 0;
    /* Critical for flex scrolling */
}

.owner-table-container,
#ownerMappingSection {
    padding: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#ownerMappingSection {
    display: none;
    /* Controlled by JS */
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 0;
    /* Critical for flex scrolling */
}

#ownerTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#ownerTable th {
    text-align: left;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

#ownerTable td {
    padding: 8px 15px;
    border-bottom: 1px solid var(--border-color);
}

#ownerTable tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Status Selector */
.status-select {
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
}

/* Status Indicators (UI & Legend) */
.status-gbr {
    color: rgb(115, 176, 118);
}

/* Green */
.status-external {
    color: rgb(238, 2, 45);
}

/* Red */
.status-declined {
    color: rgb(238, 2, 45);
}

/* Yellow -> Red */
.status-positive {
    color: rgb(48, 119, 37);
}

/* Light Green -> Dark Green */
.status-undecided {
    color: rgb(151, 197, 212);
}

/* Grey -> Light Blue */

/* Selection specific styles */
select.status-select option {
    background: var(--bg-dark);
    color: white;
}
