/* Modern CSS reset and variables */
:root {
    --bg-color: #070a13;
    --card-bg: rgba(18, 24, 41, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --accent-primary: #5850ec;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --gradient-hover: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    --accent-secondary: #06b6d4;
    --accent-teal: #10b981;
    --color-connection: #f97316;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #6b7280;
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-premium: 0 12px 40px -12px rgba(0, 0, 0, 0.6);
    
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding: 2rem 1.5rem;
}

/* Ambient Background Blobs */
.bg-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.22;
    pointer-events: none;
}
.sphere-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
    top: -100px;
    left: -100px;
}
.sphere-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #0891b2 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
}
.sphere-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
    top: 30%;
    left: 40%;
}

.app-container {
    max-width: 1440px;
    margin: 0 auto;
}

/* Header Styles */
.app-header {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.app-header .logo {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    color: var(--accent-secondary);
    filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.4));
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #ffffff;
}

.app-header h1 span {
    background: linear-gradient(120deg, var(--accent-secondary), #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header .tagline {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* Glassmorphism Card Style */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    padding: 1.8rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.8rem;
}

.card-header h2 {
    margin-bottom: 0;
}

/* Split-screen Side-by-Side Panels */
.split-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .split-view {
        grid-template-columns: 1fr;
    }
}

.part-panel {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.part-panel h2 {
    font-size: 1.25rem;
}

/* Upload zones */
.upload-box {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.01);
}

.upload-box:hover {
    border-color: var(--accent-secondary);
    background: rgba(6, 182, 212, 0.04);
}

.upload-box.dragover {
    border-color: var(--accent-teal);
    background: rgba(16, 185, 129, 0.06);
}

.upload-box.file-loaded {
    border-style: solid;
    border-color: var(--accent-teal);
    background: rgba(16, 185, 129, 0.03);
}

.upload-box.file-loaded .upload-icon {
    color: var(--accent-teal);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 5;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.upload-icon {
    width: 32px;
    height: 32px;
    color: var(--text-dark);
    transition: color 0.3s ease;
}

.upload-box:hover .upload-icon {
    color: var(--text-main);
}

.upload-content h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 500;
}

.file-info {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Maps containers */
.small-map-container {
    height: 250px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #090d16;
    overflow: hidden;
    z-index: 1;
}

.large-map-container {
    height: 420px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #090d16;
    overflow: hidden;
    margin-bottom: 1.5rem;
    z-index: 1;
}

/* Telemetry display grid */
.telemetry-box h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: #ffffff;
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.tele_item {
    display: flex;
    flex-direction: column;
}

.t_lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.t_val {
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 600;
    color: #ffffff;
    margin-top: 0.2rem;
}

/* Merged Panel details grid */
.merged-panel {
    margin-top: 1.5rem;
}

.merged-details-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2rem;
    margin-bottom: 1.8rem;
    align-items: start;
}

@media (max-width: 900px) {
    .merged-details-grid {
        grid-template-columns: 1fr;
    }
}

.merge-controls h3, .merged-stats-display h3, .charts-card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #ffffff;
}

/* Options / Sliders */
.options-section {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.option-group label {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-main);
}

.value-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.option-desc {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Sliders */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    margin: 8px 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-secondary);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
    transition: transform 0.1s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

/* Switch styling for checkbox */
.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
}

.switch-container {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
    flex-shrink: 0;
}

.switch-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 34px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.switch-container input:checked + .switch-slider {
    background-color: var(--accent-primary);
}

.switch-container input:checked + .switch-slider:before {
    transform: translateX(20px);
}

.checkbox-label {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* Inputs / Select */
.select-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    font-family: var(--font-body);
    transition: border-color 0.3s ease;
    width: 100%;
}

.select-input:focus {
    border-color: var(--accent-secondary);
}

.select-input option {
    background-color: #121829;
    color: var(--text-main);
}

/* Stats boxes in results */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.8rem;
}

.stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

/* Charts */
.charts-card {
    margin-top: 1.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.5rem;
}

.charts-container {
    width: 100%;
    height: 300px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 1.2rem 0.5rem;
}

/* Action block */
.action-section {
    margin-top: 1.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-large {
    padding: 1.1rem 2.5rem;
    width: auto;
    min-width: 280px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dark);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-icon {
    transition: transform 0.3s ease;
}

.btn:hover:not(:disabled) .btn-icon {
    transform: rotate(15deg);
}

.status-msg {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    text-align: center;
    min-height: 1.2rem;
}

.status-msg.error { color: #f87171; }
.status-msg.success { color: var(--accent-teal); }
.status-msg.loading { color: var(--accent-secondary); }

/* Legend */
.map-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-color {
    display: inline-block;
    width: 12px;
    height: 3px;
    border-radius: 2px;
}

.color-part1 { background-color: var(--accent-primary); }
.color-part2 { background-color: var(--accent-secondary); }
.color-part3 { background-color: #7c3aed; }
.color-part4 { background-color: #10b981; }
.color-connection { background-color: var(--color-connection); }

/* Hidden helper */
.hidden {
    display: none !important;
}

/* Number selector card styling */
.num-selector-card {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.selector-content {
    display: inline-flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.selector-content h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.segmented-control {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    gap: 0.25rem;
}

.segment-btn {
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 0.5rem 1.2rem;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.segment-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.03);
}

.segment-btn.active {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

/* Maximize button styling */
.btn-maximize {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-maximize:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-maximize svg {
    display: block;
}

/* Split-screen configurations for 2, 3, 4 parts */
.split-view.parts-2 {
    grid-template-columns: 1fr 1fr;
}

.split-view.parts-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.split-view.parts-4 {
    grid-template-columns: 1fr 1fr;
}

/* Maximize Overlay View */
.part-panel.maximized {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: #070a13e6;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 1.5rem;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.part-panel.maximized .small-map-container {
    flex-grow: 1;
    height: auto !important;
    min-height: 300px;
}

.part-panel.maximized .telemetry-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.part-panel.maximized .panel-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.8rem;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
