/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header Styles */
#main-header {
    backdrop-filter: blur(10px);
}

.header-gradient {
    background: linear-gradient(180deg, 
        rgba(10, 10, 42, 0.97) 0%, 
        rgba(5, 5, 25, 0.95) 100%);
    border-bottom: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    padding: 6px 16px !important;
}

.header-icon {
    animation: rotate-slow 20s linear infinite;
}

.header-icon svg {
    width: 16px;
    height: 16px;
}

@keyframes rotate-slow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.header-toggle-btn {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 6px;
    padding: 6px;
    color: #93c5fd;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.satellite-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.category-card {
    background: linear-gradient(135deg, 
        rgba(30, 30, 60, 0.35) 0%, 
        rgba(20, 20, 40, 0.35) 100%);
    border: 1px solid rgba(100, 100, 200, 0.18);
    border-radius: 6px;
    padding: 8px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(59, 130, 246, 0.5) 50%, 
        transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15),
                0 0 30px rgba(59, 130, 246, 0.1);
}

.category-card:hover::before {
    opacity: 1;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(100, 100, 200, 0.12);
}

.category-header svg {
    width: 12px;
    height: 12px;
}

.category-header h3 {
    font-size: 10px;
    font-weight: 600;
    color: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.satellite-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.satellite-chip {
    display: inline-block;
    padding: 2px 7px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 10px;
    font-size: 9px;
    color: #93c5fd;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
}

.satellite-chip:hover {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59, 130, 246, 0.5);
    color: #bfdbfe;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
    transform: scale(1.05);
}

/* Header Collapsed State */
#satellite-categories {
    max-height: 1000px;
    opacity: 1;
    transition: max-height 0.4s ease, opacity 0.3s ease;
}

#main-header.collapsed #satellite-categories {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

#main-header.collapsed {
    background: rgba(10, 10, 42, 0.85);
}


/* Canvas Container - Beautiful deep space background */
#canvas-container {
    background: radial-gradient(ellipse at center, #0a0a2a 0%, #020208 50%, #000000 100%);
}

#satellite-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#satellite-canvas:active {
    cursor: grabbing;
}

/* Custom Scrollbar for Info Panels */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.8);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.9);
}

/* Search Results Styling */
#search-results {
    scrollbar-width: thin;
    scrollbar-color: rgba(75, 85, 99, 0.8) rgba(31, 41, 55, 0.5);
}

#search-results::-webkit-scrollbar {
    width: 6px;
}

#search-results::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.3);
    border-radius: 3px;
}

#search-results::-webkit-scrollbar-thumb {
    background: rgba(75, 85, 99, 0.6);
    border-radius: 3px;
}

#search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.8);
}

/* Satellite Label Styles (for Three.js CSS2DRenderer) */
.satellite-label {
    color: #ffffff;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* Glow Effects for UI Elements */
.glow-red {
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.6), 0 0 20px rgba(255, 0, 0, 0.3);
}

.glow-orange {
    box-shadow: 0 0 10px rgba(255, 136, 0, 0.6), 0 0 20px rgba(255, 136, 0, 0.3);
}

.glow-yellow {
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.6), 0 0 20px rgba(255, 255, 0, 0.3);
}

.glow-green {
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.6), 0 0 20px rgba(0, 255, 0, 0.3);
}

.glow-blue {
    box-shadow: 0 0 10px rgba(0, 136, 255, 0.6), 0 0 20px rgba(0, 136, 255, 0.3);
}

/* Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse-slow {
    animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Adjust sidebars to account for header */
#left-sidebar {
    margin-top: 56px; /* Space for collapsed header */
    transition: margin-top 0.4s ease;
}

#legend-sidebar {
    margin-top: 56px; /* Space for collapsed header */
    transition: margin-top 0.4s ease;
}

/* Mobile Optimizations - iOS & Android */
@media (max-width: 768px) {
    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Header Responsive - Ultra Compact */
    #main-header .header-gradient {
        padding: 5px 10px !important;
    }

    #main-header h1 {
        font-size: 13px;
    }

    #main-header p {
        font-size: 8px;
    }

    .header-icon svg {
        width: 14px;
        height: 14px;
    }

    .header-toggle-btn {
        padding: 5px;
    }

    .header-toggle-btn svg {
        width: 14px;
        height: 14px;
    }

    .satellite-categories-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .category-card {
        padding: 6px;
    }

    .category-header {
        margin-bottom: 5px;
        padding-bottom: 4px;
    }

    .category-header h3 {
        font-size: 9px;
    }

    .category-header svg {
        width: 10px;
        height: 10px;
    }

    .satellite-chip {
        padding: 2px 5px;
        font-size: 8px;
        border-radius: 8px;
    }
    
    /* Make categories single column on mobile */
    .satellite-categories-grid {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
    }

    /* Left Sidebar - Hidden by default on mobile */
    #left-sidebar {
        position: fixed;
        top: 48px;
        left: -100%;
        width: 85vw;
        max-width: 320px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        margin-top: 0 !important;
        transition: left 0.3s ease;
        z-index: 40;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    #left-sidebar.mobile-open {
        left: 0;
    }

    #left-sidebar > div {
        padding: 10px;
        font-size: 0.8rem;
    }

    #left-sidebar h3 {
        font-size: 0.7rem;
    }

    #left-sidebar button {
        padding: 7px 10px;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    #left-sidebar input,
    #left-sidebar select {
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    /* Right Sidebar - Hidden on mobile, show as overlay when needed */
    #legend-sidebar {
        display: block !important;
        position: fixed;
        top: 48px;
        right: -100%;
        padding: 8px;
        font-size: 0.65rem;
        max-width: 160px;
        margin-top: 0 !important;
        transition: right 0.3s ease;
        z-index: 40;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    }

    #legend-sidebar.mobile-open {
        right: 0 !important;
    }

    #legend-sidebar h3 {
        font-size: 0.75rem;
        margin-bottom: 6px;
    }

    #legend-sidebar .text-sm {
        font-size: 0.65rem;
    }

    #legend-sidebar .w-3 {
        width: 8px;
        height: 8px;
    }

    #legend-sidebar .text-xs {
        font-size: 0.6rem;
    }

    /* Bottom Toolbar - Compact Mobile */
    #bottom-toolbar {
        bottom: 6px;
        left: 6px;
        right: 6px;
        transform: none;
        width: auto;
        padding: 6px 8px;
        flex-wrap: nowrap;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #bottom-toolbar > div {
        margin: 0;
        flex-shrink: 0;
    }

    #bottom-toolbar .text-sm {
        font-size: 0.65rem;
    }

    #bottom-toolbar button {
        padding: 5px 8px;
        font-size: 0.65rem;
        white-space: nowrap;
    }

    #bottom-toolbar .h-6 {
        display: none; /* Hide dividers on mobile */
    }

    /* Satellite Info Panel - Compact on Mobile */
    #satellite-info {
        left: 6px;
        right: 6px;
        bottom: 52px;
        top: auto;
        max-width: calc(100vw - 12px);
        padding: 8px;
        font-size: 0.7rem;
        max-height: 35vh;
        overflow-y: auto;
    }

    #satellite-info h3 {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    #satellite-info .text-sm {
        font-size: 0.65rem;
        line-height: 1.3;
    }

    #satellite-info p {
        font-size: 0.65rem;
        margin: 2px 0;
    }

    #satellite-info button {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    /* Satellite Search */
    #satellite-search {
        padding: 10px;
    }

    #satellite-search input {
        font-size: 0.7rem;
        padding: 5px 8px;
    }

    #satellite-search h3 {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }

    #search-input {
        font-size: 0.75rem;
        padding: 8px;
    }

    #search-results {
        max-height: 150px;
    }

    /* Loading Indicator */
    #loading-indicator {
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        padding: 8px 16px;
        font-size: 0.75rem;
    }

    /* Improve touch targets for iOS & Android */
    button, a, input, select {
        min-height: 36px;
        min-width: 36px;
    }

    /* Touch-friendly scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent double-tap zoom */
    * {
        touch-action: manipulation;
    }

    /* Prevent text selection during touch interactions */
    .no-select {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Mobile Floating Action Buttons */
    .mobile-fab {
        position: fixed;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: rgba(59, 130, 246, 0.9);
        border: 2px solid rgba(59, 130, 246, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
        cursor: pointer;
        z-index: 50;
        transition: all 0.2s ease;
    }

    .mobile-fab:active {
        transform: scale(0.95);
        background: rgba(59, 130, 246, 1);
    }

    #mobile-menu-btn {
        top: 60px;
        left: 10px;
        transition: opacity 0.3s ease;
    }

    #mobile-legend-btn {
        top: 60px;
        right: 10px;
        transition: opacity 0.3s ease;
    }

    /* Mobile overlay backdrop */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 35;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Header collapsed by default on mobile */
    #main-header.collapsed {
        max-height: 48px;
        overflow: hidden;
    }

    #main-header.expanded {
        max-height: 70vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    #main-header.collapsed #satellite-categories {
        display: none !important;
    }

    #main-header.expanded #satellite-categories {
        display: grid !important;
        margin-top: 8px;
        padding-bottom: 8px;
    }
    

    /* Satellite labels - smaller on mobile */
    .satellite-label {
        font-size: 9px;
        padding: 1px 4px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    #left-sidebar {
        font-size: 0.75rem;
    }

    /* Legend sidebar hidden by default but can be shown via mobile-open */
    #legend-sidebar {
        display: block;
        right: -100%;
    }
    
    #legend-sidebar.mobile-open {
        display: block;
        right: 0;
    }

    #bottom-toolbar {
        font-size: 0.65rem;
    }

    #bottom-toolbar button svg {
        width: 16px;
        height: 16px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #left-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: calc(100vh - 100px);
    }

    #left-sidebar > div {
        flex: 1 1 auto;
        min-width: 200px;
        margin: 4px;
    }

    #legend-sidebar {
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
}

/* Smooth Transitions */
button {
    transition: all 0.2s ease-in-out;
}

button:active {
    transform: scale(0.95);
}

/* Loading Spinner */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

