/* ═══════════════════════════════════════
   LAYERS — Section labels, basemaps, layer cards, groups, toggles, controls
   ═══════════════════════════════════════ */

/* ─── SECTION LABELS ─── */
.section-label {
    font-size: 10px; font-weight: 700; color: var(--text-accent);
    text-transform: uppercase; letter-spacing: 0.13em; margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
}
.section-label::before { content: ''; width: 2px; height: 10px; background: linear-gradient(180deg, var(--accent-sky), var(--accent-blue)); border-radius: 2px; flex-shrink: 0; }

.section-label-with-toggle { font-size: 10px; font-weight: 700; color: var(--text-accent); text-transform: uppercase; letter-spacing: 0.13em; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-label-text { display: flex; align-items: center; gap: 8px; }
.section-label-text::before { content: ''; width: 2px; height: 10px; background: linear-gradient(180deg, var(--accent-sky), var(--accent-blue)); border-radius: 2px; }

/* ─── BASEMAP GRID ─── */
.basemap-section { margin-bottom: 16px; }

.basemap-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; width: 100%; }

.basemap-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 7px 2px; text-align: center;
    cursor: pointer;
    transition: all .2s var(--ease-out);
    position: relative; overflow: hidden;
}

.basemap-card::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at center, var(--accent-sky), transparent 70%);
    opacity: 0; transition: opacity .2s;
}

.basemap-card:hover { border-color: var(--border-accent); background: rgba(56,189,248,0.06); transform: translateY(-1px); }
.basemap-card:hover::before { opacity: 0.08; }
.basemap-card.active { background: rgba(56,189,248,0.1); border-color: var(--border-accent); box-shadow: 0 0 12px rgba(56,189,248,0.18); }

.basemap-icon { font-size: 0; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; }
.basemap-name { font-size: 9px; font-weight: 600; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── LAYER CARDS ─── */
.layer-list { display: flex; flex-direction: column; gap: 6px; }

.layer-card {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 12px 14px;
    transition: all .22s var(--ease-out);
    position: relative; overflow: hidden; cursor: pointer;
}

.layer-card.layer-base { background: rgba(56,189,248,0.05); border-color: rgba(56,189,248,0.18); }
.layer-card.layer-base .layer-name { color: var(--accent-sky); }
.layer-card.layer-base .toggle-slider { opacity: 0.7; cursor: pointer; }

.layer-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: linear-gradient(180deg, var(--accent-sky), var(--accent-blue));
    opacity: 0; transition: opacity .2s; border-radius: 0 2px 2px 0;
}

.layer-card:hover { background: rgba(255,255,255,0.045); border-color: var(--border-default); }
.layer-card:hover::before { opacity: 1; }

.layer-controls { display: none; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 10px; animation: fadeIn 0.3s ease; }
.layer-card.active .layer-controls { display: block; }
.color-option.active { border: 2px solid white !important; transform: scale(1.1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.layer-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.layer-info { display: flex; align-items: center; gap: 12px; flex: 1; }

.layer-icon-wrapper {
    width: 34px; height: 34px;
    background: rgba(56,189,248,0.08);
    border: 1px solid rgba(56,189,248,0.15);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 0; flex-shrink: 0;
    transition: all .3s var(--ease-spring);
}

.layer-card:hover .layer-icon-wrapper { border-color: rgba(56,189,248,0.3); box-shadow: 0 4px 14px rgba(56,189,248,0.12); }

.layer-details { flex: 1; min-width: 0; }
.layer-name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; letter-spacing: -0.02em; }
.layer-description { font-size: 10px; color: var(--text-secondary); font-weight: 500; }

/* ─── LAYER GROUPS ─── */
.layer-group {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); margin-bottom: 6px;
    overflow: hidden; transition: all .22s var(--ease-out); position: relative;
}

.layer-group:hover { border-color: var(--border-default); background: rgba(56,189,248,0.03); }

.layer-group::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: linear-gradient(180deg, var(--accent-sky), var(--accent-blue));
    opacity: 0; transition: opacity .2s; border-radius: 0 2px 2px 0; z-index: 1;
}

.layer-group:hover::before { opacity: 1; }

.layer-group-header { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; position: relative; z-index: 2; }

.group-icon-box {
    width: 34px; height: 34px;
    background: rgba(56,189,248,0.08);
    border: 1px solid rgba(56,189,248,0.15);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 0; color: var(--accent-sky);
    transition: all .3s var(--ease-spring); position: relative;
}

.layer-group:hover .group-icon-box { box-shadow: 0 4px 14px rgba(56,189,248,0.12); }

.layer-group.has-active-layers .group-icon-box::after {
    content: ''; position: absolute; top: -3px; right: -3px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent-sky); border: 1.5px solid var(--bg-surface);
    box-shadow: 0 0 5px rgba(56,189,248,0.40); z-index: 10;
    animation: pulseDot 2.5s infinite;
}

@keyframes pulseDot { 0% { box-shadow: 0 0 0 0 rgba(56,189,248,.7); } 70% { box-shadow: 0 0 0 5px rgba(56,189,248,0); } 100% { box-shadow: 0 0 0 0 rgba(56,189,248,0); } }

.layer-group.has-active-layers .group-title { color: var(--text-primary); }

.group-title { font-size: 13px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.02em; }
.group-info { display: flex; align-items: center; gap: 12px; }

.group-chevron { color: var(--text-muted); transition: transform .3s var(--ease-spring), color .2s; padding: 4px; font-size: 12px; }
.layer-group.active .group-chevron { transform: rotate(180deg); color: var(--accent-sky); }

.layer-group-content { max-height: 0; overflow: hidden; transition: max-height .45s var(--ease-out), opacity .3s var(--ease-out); opacity: 0; background: rgba(0,0,0,0.18); }
.layer-group.active .layer-group-content { max-height: 4000px; opacity: 1; padding: 6px 6px 6px 20px; border-top: 1px solid var(--border-ghost); }

/* ─── TOGGLE SWITCH ─── */
.layer-toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.layer-toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.07);
    transition: all .3s var(--ease-spring);
    border-radius: 24px; border: 1px solid var(--border-default);
}

.toggle-slider:before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 2px; bottom: 2px;
    background: rgba(200,210,230,0.82);
    transition: all .3s var(--ease-spring);
    border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--accent-sky), var(--accent-blue));
    border-color: rgba(56,189,248,0.5);
    box-shadow: 0 0 14px rgba(56,189,248,0.32);
}

input:checked + .toggle-slider:before { transform: translateX(20px); background: #fff; box-shadow: 0 2px 8px rgba(56,189,248,0.4); }

/* Group toggle */
.group-toggle { position: relative; width: 36px; height: 20px; }
.group-toggle input { opacity: 0; width: 0; height: 0; }
.group-toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.07); transition: all .3s var(--ease-spring); border-radius: 20px; border: 1px solid var(--border-default); }
.group-toggle-slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 2px; bottom: 2px; background: rgba(200,210,230,0.82); transition: all .3s var(--ease-spring); border-radius: 50%; }
.group-toggle input:checked + .group-toggle-slider { background: linear-gradient(135deg, var(--accent-sky), var(--accent-blue)); border-color: rgba(56,189,248,0.5); }
.group-toggle input:checked + .group-toggle-slider:before { transform: translateX(16px); background: #fff; }

/* ─── LAYER CONTROLS ─── */
.layer-controls {
    display: none; padding: 10px 14px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border-ghost);
    gap: 8px; flex-direction: column;
}

.layer-card.controls-active .layer-controls { display: flex; animation: fadeSlideIn .2s var(--ease-out) both; }

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

.control-group { display: flex; align-items: center; gap: 8px; }
.control-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; min-width: 72px; }

.opacity-slider { flex: 1; height: 3px; -webkit-appearance: none; appearance: none; background: linear-gradient(90deg, rgba(56,189,248,0.15), var(--accent-sky)); border-radius: 2px; outline: none; }
.opacity-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; background: var(--accent-sky); border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 2px rgba(56,189,248,0.3); transition: all .15s; }
.opacity-slider::-webkit-slider-thumb:hover { transform: scale(1.25); box-shadow: 0 0 0 3px rgba(56,189,248,0.4); }
.opacity-slider::-moz-range-thumb { width: 12px; height: 12px; background: var(--accent-sky); border-radius: 50%; cursor: pointer; border: none; box-shadow: 0 0 0 2px rgba(56,189,248,0.3); }

.opacity-value { font-size: 10px; color: var(--accent-sky); font-weight: 700; min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

.color-picker-wrapper { display: flex; gap: 5px; flex-wrap: wrap; }

.color-option { width: 18px; height: 18px; border-radius: 4px; cursor: pointer; border: 2px solid transparent; transition: all .2s; position: relative; }
.color-option:hover { transform: scale(1.18); border-color: rgba(255,255,255,0.4); }
.color-option.active { border-color: white; box-shadow: 0 0 8px currentColor; }
.color-option.active::after { content: '✓'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: white; font-size: 11px; font-weight: bold; text-shadow: 0 0 4px rgba(0,0,0,0.8); }

.custom-picker-btn { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.08); border: 1px dashed rgba(255,255,255,0.28); border-radius: 4px; cursor: pointer; position: relative; transition: all .2s; }
.custom-picker-btn:hover { background: rgba(255,255,255,0.15); }
.hidden-color-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; }
.picker-icon { font-size: 10px; z-index: 1; filter: grayscale(1); }
.custom-picker-btn.active { border-style: solid; border-color: white; }
