/* Additional Enhancement - Smooth Scrolling and Accessibility */

/* Smooth scrolling for all elements */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accessibility improvements */
button, a, .info-item {
    outline: none;
    transition: all 0.3s ease;
}

button:focus-visible, 
a:focus-visible, 
.info-item:focus-visible {
    outline: 1px solid var(--bc-primary);
    outline-offset: 0px;
}

/* Improved text selection */
::selection {
    background: var(--bc-primary);
    color: white;
}

::-moz-selection {
    background: var(--bc-primary);
    color: white;
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--bc-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Tooltip styles */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: var(--bc-dark);
    color: var(--bc-text);
    border: 1px solid var(--bc-primary);
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10004;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Better link styling in sidebar */
#sidebar a {
    text-decoration: none;
    color: inherit;
}

#sidebar a:focus {
    outline: none;
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--bc-primary);
}

/* Player status indicators */
.player-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
    margin-right: 8px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* World icon enhancement */
#sidebar fieldset#worlds a::before {
    content: '🌍';
    margin-right: 8px;
    font-size: 18px;
}

/* Enhanced contrast for better readability */
@media (prefers-contrast: high) {
    :root {
        --bc-primary: #5aa3ff;
        --bc-accent: #00e5ff;
    }
    
    #bubblecraft-topbar {
        border-bottom-width: 4px;
    }
    
    #sidebar {
        border-left-width: 3px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    #bubblecraft-topbar,
    #sidebar {
        display: none !important;
    }
    
    #map {
        margin-top: 0 !important;
        height: 100vh !important;
    }
}

/* High DPI / Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .info-icon,
    #sidebar img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Safari specific fixes */
@supports (-webkit-backdrop-filter: blur(10px)) {
    #sidebar,
    #bubblecraft-topbar {
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 10003;
    display: none;
}

.offline-indicator.show {
    display: block;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Copy IP button enhancement */
.copy-ip-button {
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-ip-button:hover {
    transform: scale(1.05);
}

.copy-ip-button:active {
    transform: scale(0.95);
}

/* Mobile landscape optimization */
@media screen and (max-height: 500px) and (orientation: landscape) {
    :root {
        --bc-topbar-height: 45px;
    }
    
    #bubblecraft-topbar .server-title {
        font-size: 16px;
    }
    
    #bubblecraft-topbar .info-item {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    #sidebar fieldset {
        margin: 10px 5px;
        padding: 8px;
    }
}

/* Dark scrollbar for better aesthetics */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bc-primary) var(--bc-darker);
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: var(--bc-darker);
}

*::-webkit-scrollbar-thumb {
    background: var(--bc-primary);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--bc-accent);
}

/* Notification animations */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Connection status badge */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.connection-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
}

.connection-status.disconnected::before {
    background: #ef4444;
    box-shadow: 0 0 6px #ef4444;
}
