/* Flight Map Styles */
:root {
    --primary-color: #2563eb; /* match gfenno.com blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #ef4444; /* route red accent harmonized */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Site-wide gradient tokens borrowed from gfenno.com theme */
    --gradient-space-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-aurora: linear-gradient(135deg, #65B6A7 0%, #9AD0C5 45%, #6f8ad9 100%);
    --gradient-cool-space: linear-gradient(135deg, #0f2a3c 0%, #1e5f9d 55%, #00c6d4 100%);
    /* Default page gradient (can be swapped by body theme class) */
    --page-gradient: var(--gradient-aurora);
}

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

body {
    font-family: var(--font-family);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Soft gradient background with a gentle light overlay for readability */
    background-image:
        radial-gradient(1200px 800px at 10% 0%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.92) 45%, rgba(255,255,255,0.98) 80%),
        var(--page-gradient);
    background-attachment: fixed, fixed;
    background-size: cover, cover;
    background-repeat: no-repeat, no-repeat;
}

/* Theme helpers (optional): swap page gradient without touching components) */
body.theme-purple { --page-gradient: var(--gradient-space-purple); }
body.theme-green  { --page-gradient: var(--gradient-aurora); }

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* prevent horizontal scroll on mobile */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

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

.logo {
    cursor: pointer;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.8;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.back-link:hover {
    color: var(--primary-color);
    background-color: var(--bg-secondary);
}

/* Main Content */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* Search Section */
.search-section {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.mode-toggle {
    display: inline-flex;
    gap: .5rem;
    margin-bottom: .75rem;
}
.mode-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: .4rem .75rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
}
.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.info-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    position: relative;
    margin-left: .35rem;
}
.info-icon::after {
    content: 'i';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    font-size: 10px;
    color: white;
    font-weight: 700;
}

.search-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

/* Multi-route input spacing and disabled states */
.route-input {
    width: 100%;
    margin: .5rem 0 1rem 0;
}

.disabled-field input {
    background: var(--bg-secondary);
    cursor: not-allowed;
    opacity: 0.8;
}

.airport-input {
    flex: 1;
    position: relative;
}

.airport-input, .airport-input input {
    min-width: 0; /* prevent flex overflow pushing input right */
}

.airport-input label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.airport-input input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s;
    display: block; /* ensure left alignment */
}

.airport-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.airport-input input::placeholder {
    color: var(--text-muted);
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.suggestion-item:hover {
    background-color: var(--bg-secondary);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-code {
    font-weight: 600;
    color: var(--primary-color);
}

.suggestion-name {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.swap-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.swap-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: rotate(180deg);
}

.calculate-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    min-width: 160px;
    justify-content: center;
}

.calculate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.calculate-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Route Info Section */
.route-info-section {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.route-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.route-info-header:hover {
    background-color: var(--bg-secondary);
}

.route-info-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--primary-color);
}

.collapse-btn svg {
    transition: transform 0.2s;
}

.collapse-btn[aria-expanded="false"] svg {
    transform: rotate(180deg);
}

/* Route Info */
.route-info {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    padding: 1.5rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.route-info.collapsed {
    max-height: 0;
    padding: 0 1.5rem;
    opacity: 0;
}

.route-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.route-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.route-item .label {
    font-size: 0.875rem;
    opacity: 0.8;
    font-weight: 500;
}

.route-item .value {
    font-size: 1.125rem;
    font-weight: 700;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Segments list styling */
.segments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0 0.75rem 0;
}

.segment-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0.5rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
}

.segment-left {
    display: flex;
    gap: 0.5rem;
    font-weight: 600;
}

.segment-meta {
    opacity: 0.95;
    font-weight: 600;
}

.segments-summary {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(255,255,255,0.4);
    font-weight: 700;
}

.assumptions-note {
    margin: 0.25rem 0 0.5rem 0;
    font-size: 0.85rem;
    opacity: 0.8;
}

.welcome-note {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
}

/* Map Section */
.map-section {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

/* Ensure main blocks are centered and do not drift right on narrow screens */
.search-section,
.map-section,
.examples-section,
.route-info-section {
    margin-left: auto;
    margin-right: auto;
}

.map-container {
    position: relative;
    width: 100%;
    height: 600px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #e6f3ff;
}

#world-map {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.control-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.control-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Style hint button with three bars */
.style-hint .bars {
    display: inline-block;
    width: 16px;
    height: 12px;
    position: relative;
}
.style-hint .bars::before,
.style-hint .bars::after,
.style-hint .bars span {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
}
.style-hint .bars::before { top: 0; }
.style-hint .bars::after { bottom: 0; }
.style-hint .bars span { top: 5px; }

/* Style selector is hidden by default, shown only when toggled */
.map-style-selector {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    display: none; /* Hidden by default */
    box-shadow: var(--shadow-sm);
    min-width: 140px;
}

.map-style-selector label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.style-select {
    width: 100%;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}

.style-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(37 99 235 / 0.1);
}

/* Map style selector is now controlled by JavaScript click toggle */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Examples Section */
.examples-section {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.examples-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.example-route {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
}

.example-route:hover {
    border-color: var(--primary-color);
    background: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.route-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.route-code {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Footer */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Map Styles */
.country {
    fill: #f1f5f9;
    stroke: #cbd5e1;
    stroke-width: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
}

.country:hover {
    fill: #e2e8f0;
}

.country.detailed {
    fill: #f8fafc;
    stroke: #94a3b8;
    stroke-width: 0.3px;
}

.country.satellite {
    fill: #1e293b;
    stroke: #334155;
    stroke-width: 0.3px;
}

/* City Markers */
.city-dot {
    fill: #f59e0b;
    stroke: white;
    stroke-width: 1px;
    opacity: 0.8;
}

.city-label {
    fill: #374151;
    font-size: 8px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
}

.city-marker:hover .city-dot {
    fill: #d97706;
    opacity: 1;
}

.city-marker:hover .city-label {
    fill: #111827;
    font-weight: 600;
}

/* Geographical Features */
.geo-dot {
    fill: #10b981;
    stroke: white;
    stroke-width: 1px;
    opacity: 0.7;
}

.geo-label {
    fill: #065f46;
    font-size: 7px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    opacity: 0.8;
}

.geo-feature:hover .geo-dot {
    fill: #059669;
    opacity: 1;
}

.geo-feature:hover .geo-label {
    fill: #064e3b;
    font-weight: 600;
    opacity: 1;
}

.geo-feature.desert .geo-dot { fill: #f59e0b; }
.geo-feature.forest .geo-dot { fill: #059669; }
.geo-feature.mountains .geo-dot { fill: #6b7280; }
.geo-feature.reef .geo-dot { fill: #06b6d4; }
.geo-feature.canyon .geo-dot { fill: #dc2626; }
.geo-feature.peak .geo-dot { fill: #4b5563; }

.airport-marker {
    fill: var(--primary-color);
    stroke: white;
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.airport-marker:hover {
    fill: var(--primary-hover);
    /* Do not change radius on hover to avoid oversized markers */
}

.flight-path {
    fill: none;
    stroke: var(--accent-color);
    stroke-width: 2px;
    stroke-dasharray: none;
    opacity: 0.9;
}

/* No animation by default for comparison readability */

.airport-label {
    fill: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem; /* balance left/right spacing */
    }
    
    .search-row {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch; /* ensure full-width alignment */
    }

    /* Center the Calculate Route button on mobile */
    .calculate-btn {
        margin: 0 auto;         /* center horizontally */
        width: 100%;            /* comfortable tap target */
        max-width: 320px;       /* avoid overly wide button */
    }
    
    /* Center the contents of the blue route info card for mobile */
    .route-info {
        text-align: center;
        padding: 1.25rem;
    }
    .route-info .route-item {
        align-items: center;
    }
    .welcome-note,
    .assumptions-note {
        text-align: center;
    }
    
    .swap-btn {
        order: 3;
        align-self: center;
        transform: rotate(90deg);
    }
    
    .swap-btn:hover {
        transform: rotate(270deg);
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .examples-grid {
        grid-template-columns: 1fr;
    }
    
    .map-container {
        height: 400px;
    }
    
    .route-details {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .search-section,
    .map-section,
    .examples-section {
        padding: 1rem;
    }
    
    .main {
        padding: 1rem 0;
    }
}
