/* ===========================================
   Satellite Tracker - Space Theme CSS
   Deep dark UI with glowing accents
   =========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2236;
    --bg-hover: #1f2b42;
    --bg-active: #253352;
    --text-primary: #e8ecf4;
    --text-secondary: #8b95a8;
    --text-muted: #5a6478;
    --accent-cyan: #00d4ff;
    --accent-green: #00ffaa;
    --accent-gold: #ffd700;
    --accent-pink: #ff6b9d;
    --border-color: rgba(255, 255, 255, 0.06);
    --glow-cyan: 0 0 20px rgba(0, 212, 255, 0.15);
    --glow-green: 0 0 20px rgba(0, 255, 170, 0.15);
    --sidebar-width: 320px;
    --info-panel-width: 380px;
    --header-height: 52px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- Loading Overlay ---- */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    gap: 24px;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 212, 255, 0.15);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ---- Header ---- */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(180deg, rgba(10, 14, 23, 0.95) 0%, rgba(10, 14, 23, 0.7) 100%);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

#toggle-sidebar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 18px;
}

#toggle-sidebar:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 22px;
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.5));
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 2px;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 12px;
}

#sat-counter {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 5px 14px;
    background: rgba(0, 255, 170, 0.06);
    border: 1px solid rgba(0, 255, 170, 0.15);
    border-radius: 20px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#utc-clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--accent-cyan);
    padding: 5px 14px;
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.12);
    border-radius: 8px;
    letter-spacing: 0.5px;
}

/* ---- Layout ---- */
#app-container {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    display: flex;
}

/* ---- Sidebar ---- */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 50;
    overflow: hidden;
}

#sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar-section {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

/* ---- Category Filters ---- */
#category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 11px;
    font-family: inherit;
    white-space: nowrap;
}

.category-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.category-btn.active {
    background: rgba(0, 212, 255, 0.08);
    border-color: rgba(0, 212, 255, 0.2);
    color: var(--text-primary);
}

.cat-icon {
    font-size: 13px;
}

.cat-name {
    font-weight: 500;
}

.cat-count {
    font-size: 10px;
    color: var(--text-muted);
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* ---- Satellite List ---- */
#satellite-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sat-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.sat-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.sat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    padding-left: 36px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 2px solid transparent;
}

.sat-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.sat-checkbox:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 4px rgba(0, 212, 255, 0.2);
}

.sat-checkbox:checked {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.4);
}

.sat-checkbox:checked::after {
    content: '✓';
    font-size: 10px;
    color: var(--bg-primary);
    font-weight: 700;
}

.sat-item:hover {
    background: var(--bg-hover);
}

.sat-item.active {
    background: var(--bg-active);
    border-left-color: var(--accent-cyan);
}

.sat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

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

.sat-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.sat-alt {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 2px;
}

/* ---- Cesium Container ---- */
#cesium-container {
    flex: 1;
    height: 100%;
    position: relative;
}

/* Override Cesium widget styles */
.cesium-widget,
.cesium-widget canvas {
    width: 100% !important;
    height: 100% !important;
}

.cesium-widget-credits {
    display: none !important;
}

/* ---- Info Panel ---- */
#info-panel {
    position: fixed;
    right: -420px;
    top: var(--header-height);
    bottom: 0;
    width: var(--info-panel-width);
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-color);
    z-index: 80;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 20px;
}

#info-panel.visible {
    right: 0;
}

#close-info {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

#close-info:hover {
    background: rgba(255, 100, 100, 0.1);
    border-color: rgba(255, 100, 100, 0.2);
    color: #ff6b6b;
}

/* ---- Info Panel Content ---- */
.info-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.info-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.3));
}

.info-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.info-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.info-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    transition: var(--transition);
}

.info-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(0, 212, 255, 0.15);
}

.info-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.info-value {
    display: block;
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-cyan);
    font-weight: 500;
}

.info-coords {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
}

.info-coord-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.info-coord-title:not(:first-child) {
    margin-top: 12px;
}

.info-coord-values {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
    line-height: 1.6;
    word-break: break-all;
}

/* ---- Animations ---- */
@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 4px currentColor; }
    50% { box-shadow: 0 0 10px currentColor; }
}

.sat-dot {
    animation: glow-pulse 3s ease-in-out infinite;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
        --info-panel-width: 320px;
    }

    .logo-sub {
        display: none;
    }
}

@media (max-width: 480px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        z-index: 90;
    }

    #sidebar.collapsed {
        left: calc(-1 * var(--sidebar-width));
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }
}

/* ---- Sidebar Add Button & Actions ---- */
.sidebar-actions {
    display: flex;
    justify-content: center;
    padding: 2px 0;
}

.action-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 255, 170, 0.15));
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    color: var(--accent-cyan);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.3), rgba(0, 255, 170, 0.3));
    border-color: var(--accent-green);
    box-shadow: 0 0 12px rgba(0, 255, 170, 0.25);
    color: var(--text-primary);
}

/* ---- Modal Dialog ---- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(5, 7, 12, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.visible {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 212, 255, 0.1);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.form-group input[type="text"] {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    transition: var(--transition);
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
}

.form-group textarea {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    min-height: 180px;
    resize: vertical;
    line-height: 1.5;
    transition: var(--transition);
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.primary-btn {
    background: var(--accent-cyan);
    color: var(--bg-primary);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--text-primary);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}

.secondary-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* ---- Collapsible Group Header Elements ---- */
.sat-group-toggle-arrow {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 10px;
    transition: transform 0.2s ease;
}

.sat-group.collapsed .sat-group-toggle-arrow {
    transform: rotate(-90deg);
}

.sat-group-title {
    flex: 1;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sat-group-count {
    font-size: 9px;
    color: var(--text-muted);
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.sat-group-content {
    overflow: hidden;
    max-height: 1500px;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
}

.sat-group.collapsed .sat-group-content {
    max-height: 0 !important;
}

.sat-group-delete, .sat-item-delete {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    opacity: 0;
    transition: var(--transition);
}

.sat-group-header:hover .sat-group-delete,
.sat-item:hover .sat-item-delete {
    opacity: 1;
}

.sat-group-delete:hover {
    background: rgba(255, 100, 100, 0.15);
    color: #ff6b6b;
}

.sat-item-delete:hover {
    background: rgba(255, 100, 100, 0.15);
    color: #ff6b6b;
}
