/* BubbleCraft Custom Styles - Minimal & Modern */

:root {
    --bc-primary: #3b82f6;
    --bc-secondary: #8b5cf6;
    --bc-dark: #0f172a;
    --bc-darker: #020617;
    --bc-accent: #06b6d4;
    --bc-text: #f8fafc;
    --bc-text-dim: #94a3b8;
    --bc-border: rgba(148, 163, 184, 0.2);
    --bc-sidebar-width: 260px;
    --bc-topbar-height: 56px;
}

/* Top Navigation Bar */
#bubblecraft-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--bc-topbar-height);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bc-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10001;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#bubblecraft-topbar .logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

#bubblecraft-topbar .logo {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(74, 144, 226, 0.5));
}

#bubblecraft-topbar .server-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--bc-text);
    letter-spacing: -0.01em;
}

#bubblecraft-topbar .server-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

#bubblecraft-topbar .info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    color: var(--bc-text-dim);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s ease;
}

#bubblecraft-topbar .info-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--bc-primary);
    color: var(--bc-text);
}

#bubblecraft-topbar .info-icon {
    width: 20px;
    height: 20px;
    filter: brightness(1.2);
}

#bubblecraft-topbar .menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--bc-text);
    font-size: 28px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s ease;
}

#bubblecraft-topbar .menu-toggle:hover {
    color: var(--bc-primary);
}

/* Adjust map container for top bar */
#map {
    margin-top: var(--bc-topbar-height);
    height: calc(100vh - var(--bc-topbar-height));
}

/* Enhanced Sidebar Styling */
#sidebar {
    width: var(--bc-sidebar-width) !important;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-left: 1px solid var(--bc-border);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    padding: 0 !important;
    overflow-y: auto;
    overflow-x: hidden;
}

#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: var(--bc-darker);
}

#sidebar::-webkit-scrollbar-thumb {
    background: var(--bc-primary);
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--bc-accent);
}

/* Sidebar always shown */
#sidebar.show {
    width: var(--bc-sidebar-width) !important;
}

/* Pin Button Enhancement */
#sidebar #pin {
    position: sticky;
    top: 0;
    right: auto;
    margin: 12px auto;
    width: 28px;
    height: 28px;
    padding: 4px;
    background: transparent;
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    filter: none;
    transition: all 0.2s ease;
    z-index: 100;
    cursor: pointer;
}

#sidebar #pin:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--bc-primary);
}

#sidebar #pin.pinned {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--bc-primary);
}

/* Fieldset Improvements */
#sidebar fieldset {
    margin: 12px;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
}

#sidebar legend {
    color: var(--bc-text-dim);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 8px;
    text-align: left;
    margin: 0 0 8px 0;
    float: none;
}

#sidebar fieldset#worlds {
    margin-top: 10px;
}

#sidebar fieldset#players {
    max-height: calc(100vh - var(--bc-topbar-height) - 250px);
    overflow-y: auto;
}

/* Player/World Links Enhancement */
#sidebar fieldset a,
#sidebar fieldset a:visited {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 2px 0;
    background: transparent;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    color: var(--bc-text);
    font-size: 14px;
}

#sidebar fieldset a:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--bc-border);
}

#sidebar fieldset a.following {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--bc-primary);
}

#sidebar fieldset a img {
    width: 28px;
    height: 28px;
    border-radius: 2px;
    border: 1px solid var(--bc-border);
    filter: none;
}

#sidebar fieldset#players a img {
    image-rendering: pixelated;
}

/* Coordinates Display Enhancement */
div.leaflet-control-layers.coordinates {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    color: var(--bc-text-dim);
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Link Control Enhancement */
div.leaflet-control-layers.link {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--bc-border);
    border-radius: 6px;
    transition: all 0.2s ease;
}

div.leaflet-control-layers.link:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--bc-primary);
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    :root {
        --bc-sidebar-width: 100%;
        --bc-topbar-height: 0px;
    }

    #bubblecraft-topbar {
        display: none;
    }

    #bubblecraft-topbar .logo {
        height: 30px;
    }

    #bubblecraft-topbar .server-title {
        font-size: 18px;
    }

    #bubblecraft-topbar .server-info {
        display: none;
    }

    #bubblecraft-topbar .server-info.mobile-show {
        display: none;
    }

    #bubblecraft-topbar .menu-toggle {
        display: none;
    }

    #sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 60px !important;
        max-width: none;
        transition: width 0.3s ease;
        z-index: 10000;
        overflow: hidden;
    }

    #sidebar.show {
        width: 85% !important;
        max-width: 320px;
    }

    #sidebar fieldset#players {
        max-height: calc(100vh - 200px);
    }

    /* Touch-friendly controls */
    .leaflet-bar a {
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        font-size: 20px;
    }

    .leaflet-control-zoom {
        border: 2px solid var(--bc-primary) !important;
    }

    .leaflet-bar a:hover {
        background-color: var(--bc-primary) !important;
        color: white !important;
    }

    /* Mobile map adjustments */
    #map {
        margin-top: 0;
        height: 100vh;
    }
}

@media screen and (max-width: 480px) {
    #bubblecraft-topbar .server-title {
        font-size: 16px;
    }

    #bubblecraft-topbar .info-item {
        font-size: 12px;
        padding: 6px 12px;
    }

    #sidebar {
        width: 50px !important;
    }

    #sidebar.show {
        width: 95% !important;
        max-width: 300px;
    }
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#sidebar.show {
    animation: slideInRight 0.3s ease;
}

#bubblecraft-topbar {
    animation: fadeIn 0.5s ease;
}

/* Improved marker nameplates */
div.leaflet-nameplate-pane > div {
    background: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--bc-border) !important;
    border-radius: 4px;
    padding: 4px 8px;
    font-weight: 500;
    font-size: 13px;
}

/* Map controls enhancement */
.leaflet-bar {
    border: 1px solid var(--bc-border) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    border-radius: 6px !important;
}

.leaflet-bar a {
    background-color: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(8px);
    color: var(--bc-text-dim) !important;
    border-bottom: 1px solid var(--bc-border) !important;
}

.leaflet-bar a:hover {
    background-color: rgba(59, 130, 246, 0.1) !important;
    color: var(--bc-text) !important;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: var(--bc-topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bc-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    animation: fadeIn 0.3s ease;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(74, 144, 226, 0.3);
    border-top: 4px solid var(--bc-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
