/* ========================================
   SAMAWA WebGIS - Leaflet Controls
   ATR BPN Theme - Modern Futuristic
   ======================================== */

/* Theme Variables (inherit from main styles) */
:root {
    --ctrl-primary: #1a3a5c;
    --ctrl-primary-light: #2d5d8a;
    --ctrl-gold: #d4a84b;
    --ctrl-gold-light: #e8c36d;
    --ctrl-sky-blue: #87ceeb;
    --ctrl-glass-bg: rgba(26, 58, 92, 0.95);
    --ctrl-glass-border: rgba(255, 255, 255, 0.15);
    --ctrl-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    --ctrl-radius: 12px;
    --ctrl-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Custom Layer Control
   ======================================== */
.custom-layer-control {
    background: var(--ctrl-glass-bg);
    border-radius: var(--ctrl-radius);
    box-shadow: var(--ctrl-shadow);
    overflow: hidden;
    transition: var(--ctrl-transition);
    backdrop-filter: blur(12px);
    border: 1px solid var(--ctrl-glass-border);
}

.layer-control-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--ctrl-sky-blue), var(--ctrl-primary-light));
    color: white;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.5px;
}

.layer-control-header:active {
    background: linear-gradient(135deg, #6eb8d9, #1e4d6e);
}

.layer-control-header .toggle-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.layer-control-header .toggle-icon.expanded {
    transform: rotate(180deg);
}

.layer-control-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0;
}

.layer-control-body.expanded {
    max-height: 600px;
    padding: 12px;
    overflow-y: auto;
}

.layer-item {
    margin: 8px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid transparent;
    transition: var(--ctrl-transition);
}

.layer-item:hover {
    background: rgba(135, 206, 235, 0.1);
    border-color: var(--ctrl-sky-blue);
}

.layer-item.active {
    border-color: var(--ctrl-sky-blue);
    background: rgba(135, 206, 235, 0.15);
}

.layer-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.layer-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--ctrl-sky-blue);
}

.layer-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.layer-item.active .layer-name {
    color: var(--ctrl-sky-blue);
}

.layer-opacity {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--ctrl-glass-border);
    display: none;
}

.layer-item.active .layer-opacity {
    display: block;
}

.opacity-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opacity-slider-container label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    min-width: 50px;
}

.opacity-slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
}

.opacity-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--ctrl-sky-blue);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(135, 206, 235, 0.4);
}

.opacity-slider-container .opacity-value {
    font-size: 10px;
    font-weight: bold;
    color: var(--ctrl-sky-blue);
    min-width: 35px;
    text-align: right;
}

/* ========================================
   Basemap Control
   ======================================== */
.basemap-control {
    background: var(--ctrl-glass-bg);
    border-radius: var(--ctrl-radius);
    box-shadow: var(--ctrl-shadow);
    overflow: hidden;
    margin-top: 10px;
    backdrop-filter: blur(12px);
    border: 1px solid var(--ctrl-glass-border);
}

.basemap-control-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--ctrl-gold), var(--ctrl-gold-light));
    color: var(--ctrl-primary);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.5px;
}

.basemap-control-header:active {
    background: linear-gradient(135deg, #c89a3f, #d9b35e);
}

.basemap-control-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0;
}

.basemap-control-body.expanded {
    max-height: 200px;
    padding: 12px;
}

.basemap-item {
    padding: 10px 12px;
    margin: 6px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--ctrl-transition);
    border: 1px solid transparent;
}

.basemap-item:hover {
    background: rgba(212, 168, 75, 0.1);
    border-color: var(--ctrl-gold);
}

.basemap-item:active {
    background: rgba(212, 168, 75, 0.2);
}

.basemap-item.active {
    border-color: var(--ctrl-gold);
    background: rgba(212, 168, 75, 0.15);
}

.basemap-item input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ctrl-gold);
}

.basemap-item label {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
}

/* ========================================
   Geolocation Button
   ======================================== */
.leaflet-control-locate {
    background: var(--ctrl-glass-bg);
    border-radius: 10px;
    box-shadow: var(--ctrl-shadow);
    cursor: pointer;
    backdrop-filter: blur(12px);
    border: 1px solid var(--ctrl-glass-border);
}

.leaflet-control-locate a {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: var(--ctrl-transition);
    -webkit-tap-highlight-color: transparent;
}

.leaflet-control-locate a:hover {
    background: rgba(135, 206, 235, 0.15);
    color: var(--ctrl-sky-blue);
    border-radius: 10px;
}

.leaflet-control-locate a:active {
    background: rgba(135, 206, 235, 0.25);
}

.leaflet-control-locate a.loading {
    animation: pulse 1.5s infinite;
}

.leaflet-control-locate a.active {
    color: #4caf50;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ========================================
   Legend Control
   ======================================== */
.legend-wms {
    background: var(--ctrl-glass-bg);
    padding: 12px;
    border-radius: var(--ctrl-radius);
    box-shadow: var(--ctrl-shadow);
    max-height: 300px;
    overflow-y: auto;
    backdrop-filter: blur(12px);
    border: 1px solid var(--ctrl-glass-border);
}

.legend-wms h4 {
    margin: 5px 0;
    font-size: 11px;
    border-bottom: 1px solid var(--ctrl-glass-border);
    padding-bottom: 6px;
    color: var(--ctrl-gold);
}

.legend-wms img {
    display: block;
    width: auto;
    height: auto;
    max-width: 150px;
}

/* ========================================
   Info Box Control
   ======================================== */
.info-box {
    background: var(--ctrl-glass-bg);
    padding: 12px;
    border-radius: var(--ctrl-radius);
    box-shadow: var(--ctrl-shadow);
    font-size: 11px;
    max-width: 220px;
    backdrop-filter: blur(12px);
    border: 1px solid var(--ctrl-glass-border);
    color: rgba(255, 255, 255, 0.9);
}

.info-box strong {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    border-bottom: 1px solid var(--ctrl-glass-border);
    padding-bottom: 6px;
    color: var(--ctrl-gold);
}

.info-item {
    margin: 4px 0;
    line-height: 1.5;
}

/* ========================================
   Location Modal
   ======================================== */
.location-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 14, 24, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(8px);
}

.location-modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.location-modal-content {
    background: var(--ctrl-glass-bg);
    border-radius: 16px;
    padding: 28px;
    max-width: 90%;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
    border: 1px solid var(--ctrl-glass-border);
    backdrop-filter: blur(16px);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.location-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.location-modal-icon {
    font-size: 48px;
}

.location-modal-title {
    font-size: 18px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.95);
}

.location-modal-body {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 24px;
}

.location-modal-buttons {
    display: flex;
    gap: 12px;
}

.location-modal-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ctrl-transition);
    -webkit-tap-highlight-color: transparent;
}

.location-modal-btn.primary {
    background: linear-gradient(135deg, var(--ctrl-sky-blue), var(--ctrl-primary-light));
    color: white;
    box-shadow: 0 4px 15px rgba(135, 206, 235, 0.3);
}

.location-modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(135, 206, 235, 0.4);
}

.location-modal-btn.primary:active {
    transform: scale(0.98);
}

.location-modal-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--ctrl-glass-border);
}

.location-modal-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.location-modal-btn.secondary:active {
    background: rgba(255, 255, 255, 0.1);
}

/* ========================================
   Location Marker Pulse
   ======================================== */
.location-marker {
    position: relative;
}

.location-pulse {
    width: 22px;
    height: 22px;
    background: var(--ctrl-sky-blue);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 0 rgba(135, 206, 235, 0.4);
    animation: locationPulse 2s infinite;
}

.location-pulse::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes locationPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(135, 206, 235, 0.5);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(135, 206, 235, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(135, 206, 235, 0);
    }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {

    .custom-layer-control,
    .basemap-control {
        max-width: calc(70vw - 80px);
    }

    .layer-control-body.expanded {
        max-height: 400px;
    }
}