/* Enhanced Layer Control Panel - Collapsible Groups Design */

.layer-control-panel {
    position: fixed;
    right: 20px;
    top: 100px;
    width: 340px;
    max-height: calc(100vh - 140px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 250, 0.98) 100%);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 999;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.layer-control-panel.collapsed {
    transform: translateX(calc(100% + 20px));
}

.layer-panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
}

.layer-panel-header:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
}

.layer-panel-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 0.5px;
}

.layer-panel-title i {
    font-size: 22px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.layer-panel-toggle {
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 16px;
}

.layer-panel-toggle:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1) rotate(180deg);
}

.layer-panel-content {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding: 20px;
}

.layer-panel-content::-webkit-scrollbar {
    width: 8px;
}

.layer-panel-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.layer-panel-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.layer-panel-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
}

.layer-stats {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 15px;
    padding: 18px;
    margin-bottom: 20px;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.layer-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.layer-stat-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.layer-stat-label {
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

.layer-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #667eea;
    background: white;
    padding: 4px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* Layer Group Styles - Collapsible */
.layer-group {
    margin-bottom: 15px;
}

.layer-group-header {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.layer-group-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.layer-group-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.layer-group-arrow {
    margin-left: auto;
    font-size: 14px;
    color: #666;
    transition: transform 0.3s ease;
}

/* Layer Group Content - Collapsible */
.layer-group-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease;
    opacity: 1;
    padding-top: 10px;
}

.layer-group-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 14px;
    margin: 8px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.layer-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transform: translateX(5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: rgba(102, 126, 234, 0.3);
}

.layer-item.active {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25);
}

.layer-checkbox {
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-radius: 8px;
    margin-right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.layer-checkbox.checked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    animation: checkPop 0.3s ease;
}

@keyframes checkPop {
    0% {
        transform: scale(0.8);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.layer-checkbox.checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    font-size: 14px;
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-count {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.layer-color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-left: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    border: 2px solid white;
}

/* Toggle Button (when panel is collapsed) */
.layer-toggle-btn {
    position: fixed;
    right: 20px;
    top: 100px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 998;
    transition: all 0.3s ease;
}

.layer-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

.layer-toggle-btn:active {
    transform: scale(0.95);
}

.layer-control-panel.collapsed+.layer-toggle-btn {
    display: flex;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .layer-control-panel {
        width: 300px;
        right: 10px;
        top: 90px;
    }

    .layer-toggle-btn {
        right: 10px;
        top: 90px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .layer-panel-content {
        padding: 15px;
    }

    .layer-item {
        padding: 12px;
    }
}

/* Smooth transitions for all interactive elements */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Add subtle glow effect to active items */
.layer-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 0 0 12px;
}

.layer-item {
    position: relative;
}

/* Improve text readability */
.layer-panel-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}