/* SunInFlight - Theme Support */

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

/* Light Theme (Default - matches Android screenshot) */
:root, .theme-light {
    --bg: #F5F5F5;
    --card-bg: #FFFFFF;
    --text: #1A237E;
    --text-secondary: #5C6BC0;
    --border: #E0E0E0;
    --primary: #1976D2;
    --primary-hover: #1565C0;
    --accent: #2196F3;
    --input-bg: #FAFAFA;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Dark Theme */
.theme-dark {
    --bg: #0A0E27;
    --card-bg: #1a1f3a;
    --text: #E8EAF6;
    --text-secondary: #9FA8DA;
    --border: #303F9F;
    --primary: #003D82;
    --primary-hover: #0058B8;
    --accent: #FFC72C;
    --input-bg: #0f1429;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.app-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
}

/* Install Banner */
.install-banner {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    color: white;
    padding: 16px 20px;
    margin: 0 0 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.install-banner-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.install-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.install-banner-text strong {
    font-size: 16px;
    font-weight: 600;
}

.install-banner-text span {
    font-size: 13px;
    opacity: 0.9;
}

.install-banner-btn {
    background: white;
    color: #1976D2;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.install-banner-btn:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.install-banner-btn:active {
    transform: translateY(0);
}

.install-banner-dismiss {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.install-banner-dismiss:hover {
    background: rgba(255,255,255,0.3);
}

@media (max-width: 640px) {
    .install-banner {
        padding: 12px 16px;
        margin: 0 0 16px 0;
    }
    
    .install-banner-content {
        gap: 12px;
    }
    
    .install-banner-icon {
        font-size: 24px;
    }
    
    .install-banner-text strong {
        font-size: 14px;
    }
    
    .install-banner-text span {
        font-size: 12px;
    }
    
    .install-banner-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* Header */
/* Header */
header {
    background: linear-gradient(135deg, #05164D 0%, #0066CC 100%);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
}

/* Version Badge */
.version-badge {
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    color: white;  /* ← Weiße Schrift! */
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    vertical-align: middle;
    letter-spacing: 0.03em;
    opacity: 0.85;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.3s;
    color: white;
}

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

/* Legacy support */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 16px;
}

.app-header h1 {
    font-size: 1.5em;
    color: var(--primary);
    font-weight: 500;
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Clear Button */
.clear-all-btn {
    width: 100%;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--primary);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px var(--shadow);
    transition: all 0.3s;
}

.clear-all-btn:hover {
    background: var(--input-bg);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.card h3 {
    color: var(--primary);
    font-size: 1.2em;
    font-weight: 500;
    margin-bottom: 16px;
}

/* Form Layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;  /* Consistent spacing between rows */
}

/* Airport row with swap button - 3 columns */
.form-row.airports-row {
    grid-template-columns: 1fr auto 1fr;
    align-items: end;  /* Align all items (including swap button) to bottom */
}

.form-row:last-child {
    margin-bottom: 0;
}

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

.form-group label {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-top: 4px;
    margin-bottom: 1px;
}

.form-row:first-child .form-group label {
    margin-top: 0;
}

.form-group small {
    color: var(--text-secondary);
    font-size: 0.8em;
    margin-top: 4px;
}

/* Inputs */
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .icon {
    position: absolute;
    left: 12px;
    font-size: 1.2em;
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 44px !important;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1em;
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.highlighted input {
    border: 2px solid var(--primary);
    background: rgba(33, 150, 243, 0.05);
}

/* Swap Button */
.swap-btn {
    align-self: end;  /* Align to bottom of grid cell */
    margin-bottom: 0;  /* No bottom margin */
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.3em;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px var(--shadow);
}

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

/* Calculate Button / Primary Button */
.primary-btn,
.calculate-btn {
    background: var(--accent-blue, #0066CC);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    width: 100%;
    margin-bottom: 16px;
}

.primary-btn:hover,
.calculate-btn:hover {
    background: var(--accent-hover, #004C99);
    transform: translateY(-2px);
}

/* Results */
.results-card {
    padding: 16px;
    margin-bottom: 6px;
}

.results-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.result-column h4 {
    color: var(--primary);
    font-size: 1em;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.result-column {
    font-size: 0.9em;
    line-height: 1.3;
}

.result-column div {
    margin-bottom: 4px;
}

/* Events */
.event-item {
    background: var(--input-bg);
    border-left: 3px solid var(--accent);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
}

.event-time {
    font-size: 1em;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.event-details {
    font-size: 0.85em;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Waypoints (Collapsible) */
.waypoints-card {
    cursor: pointer;
}

.waypoints-card summary {
    font-size: 1.2em;
    color: var(--primary);
    font-weight: 500;
    padding: 4px 0;
    list-style: none;
    user-select: none;
}

.waypoints-card summary::-webkit-details-marker {
    display: none;
}

.waypoints-card summary::before {
    content: "▶ ";
    display: inline-block;
    transition: transform 0.3s;
}

.waypoints-card[open] summary::before {
    transform: rotate(90deg);
}

#waypointsContainer {
    margin-top: 16px;
}

.waypoint-row {
    display: grid;
    grid-template-columns: 1fr 1fr 80px;
    gap: 8px;
    margin-bottom: 8px;
}

.waypoint-row input {
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9em;
}

/* Autocomplete */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px; /* Increased from 200px */
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 8px var(--shadow);
    margin-top: -1px;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
    transition: background 0.2s;
}

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

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

.autocomplete-item strong {
    color: var(--primary);
}

/* Mobile Responsive */
/* Only switch to 1-column on VERY small screens (under 350px) */
@media (max-width: 349px) {
    .form-row,
    .form-row.airports-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .swap-btn {
        margin-top: 0;
        width: 100%;
        border-radius: 8px;
    }
    
    .results-columns {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Responsive: Min-width 350px for 2-column on large phones */
.app-container {
    min-width: 350px;
}

/* Airport row positioning */
.airports-row {
    position: relative;
}

.airport-group {
    position: relative;
}

/* Autocomplete directly under field */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    margin-top: 4px;
}

/* Times row - equal width */
.times-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.times-row .form-group {
    margin: 0;
}

/* Update Banner (same style as install banner but orange) */
.update-banner {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    padding: 16px 20px;
    margin: 0 0 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

@media (max-width: 640px) {
    .update-banner {
        padding: 12px 16px;
        margin: 0 0 16px 0;
    }
}
/* COMPACT MODE - Reduce vertical spacing */

.app-container {
    padding: 12px; /* was 16px */
}

.install-banner, .update-banner {
    padding: 12px 16px; /* was 16px 20px */
    margin: 0 0 12px 0; /* was 0 0 20px 0 */
}

.app-header {
    padding: 12px 0; /* was 20px 0 */
    margin-bottom: 12px; /* was 16px */
}

.card {
    padding: 16px; /* was 20px */
    margin-bottom: 12px; /* add */
}

.form-row {
    gap: 8px; /* was 12px */
    margin-bottom: 12px; /* was 16px */
}

.form-group {
    gap: 4px; /* reduce internal spacing */
}

.form-group label {
    margin-bottom: 1px; /* minimal spacing */
    font-size: 0.85em; /* was 0.9em */
}

.form-group small {
    margin-top: 2px; /* was 4px */
    font-size: 0.75em; /* smaller */
}

.input-with-icon input {
    padding: 8px 8px 8px 36px; /* was 10px 10px 10px 40px */
}

input[type="text"], input[type="date"] {
    padding: 8px; /* was 10px */
}

.calculate-btn, .clear-all-btn {
    padding: 10px; /* was 12px */
    margin-top: 8px; /* was 12px */
}

.results-columns {
    gap: 12px; /* was 20px */
}

.result-column {
    padding: 12px; /* reduce internal padding */
    line-height: 1.3; /* compact like FLIGHT card */
}

.event-item {
    padding: 8px; /* was 12px */
    margin-bottom: 6px; /* was 8px */
}

/* Compact autocomplete */
.autocomplete-results {
    max-height: 250px; /* was 300px */
}

.autocomplete-item {
    padding: 8px; /* was 12px */
    font-size: 0.85em; /* was 0.9em */
}

/* iOS Install Instructions Banner */
.ios-install-banner {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    padding: 12px 16px;
    margin: 0 0 12px 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    animation: slideDown 0.3s ease-out;
}

.ios-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ios-install-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.ios-install-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ios-install-text strong {
    font-size: 15px;
    font-weight: 600;
}

.ios-install-text span {
    font-size: 13px;
    opacity: 0.95;
    line-height: 1.3;
}

@media (max-width: 640px) {
    .ios-install-banner {
        padding: 10px 12px;
    }
    
    .ios-install-icon {
        font-size: 24px;
    }
    
    .ios-install-text strong {
        font-size: 14px;
    }
    
    .ios-install-text span {
        font-size: 12px;
    }
}

/* ULTRA COMPACT MODE - Minimal spacing */
.app-container {
    padding: 1px !important;
}

.card {
    margin-bottom: 1px !important;
}

.form-row {
    margin-bottom: 1px !important;
}

.install-banner, .update-banner, .ios-install-banner {
    margin: 0 0 1px 0 !important;
}

/* Reduced padding/margins */
.app-header {
    padding: 8px 0 !important;
    margin-bottom: 8px !important;
}

.app-header h1 {
    font-size: 1.4em;
    margin: 0;
}

.card h3 {
    margin-bottom: 8px !important;
    padding-bottom: 4px !important;
}

.card {
    padding: 12px !important;
}

/* Sun/Moon Timeline Visualization */
.timeline-card {
    margin-top: 6px;
    margin-bottom: 6px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.timeline-card h4 {
    margin: 0 0 12px 0;
    font-size: 0.95em;
    color: var(--text);
}

/* Middle third duration label */
.timeline-third-label {
    text-align: center;
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 500;
}

/* Container for markers and timeline bars */
.timeline-container {
    position: relative;
    margin-bottom: 8px;
}

/* Reversed timeline for westward flights */
.timeline-container.timeline-reversed .timeline-bar,
.timeline-row.timeline-reversed .timeline-bar {
    flex-direction: row-reverse;  /* Reverse segment order */
}

.timeline-container.timeline-reversed .timeline-markers {
    transform: scaleX(-1);  /* Mirror markers */
}

.timeline-container.timeline-reversed .time-marker {
    transform: scaleX(-1) translateX(50%);  /* Un-mirror text, adjust position */
}

/* Time markers directly above sun timeline */
.timeline-markers {
    position: relative;
    height: 30px;
    margin-bottom: 2px;
}

.time-marker {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.marker-label {
    font-size: 0.65em;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    margin-bottom: 2px;
}

.marker-line {
    width: 1px;
    height: 16px;
    background: var(--text-secondary);
    opacity: 0.5;
}

.timeline-row {
    margin-bottom: 0;
    position: relative;
}

.timeline-label {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 4px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.timeline-arrows {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    pointer-events: none;
}

.timeline-arrows span {
    position: absolute;
    transform: translateX(-50%);
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary);
}

.timeline-bar {
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    position: relative;
    background: var(--input-bg);
    border: 1px solid var(--border);
}

/* Flight info BETWEEN sun and moon */
.timeline-flight-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
    padding: 4px 0;
    font-size: 0.75em;
    color: var(--text-secondary);
}

.flight-info-left {
    text-align: left;
}

.flight-info-center {
    text-align: center;
    font-weight: 600;
    color: var(--text);
}

.flight-info-right {
    text-align: right;
}

.timeline-segment {
    height: 100%;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: 600;
    color: rgba(0,0,0,0.7);
    border-right: 1px solid rgba(255,255,255,0.3);
}

.timeline-segment:last-child {
    border-right: none;
}

/* Sun states */
.sun-visible {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
}

.sun-transition {
    background: linear-gradient(135deg, #FF8C00 0%, #FF6347 100%);
}

.sun-not-visible {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
}

/* Moon states */
.moon-visible {
    background: linear-gradient(135deg, #D1D5DB 0%, #E5E7EB 100%); /* Light gray - moon is visible! */
}

.moon-transition {
    background: linear-gradient(135deg, #FF8C00 0%, #FF6347 100%);
}

.moon-not-visible {
    background: linear-gradient(135deg, #4B5563 0%, #6B7280 100%); /* Dark gray - moon not visible */
}

.timeline-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 0.75em;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* ===== Footer ===== */
.app-footer {
    background: var(--card-bg, #FFFFFF);
    border-top: 1px solid var(--border, #E0E0E0);
    padding: 1.5rem;
    text-align: center;
    margin-top: 3rem;
    color: var(--text-secondary, #666666);
    font-size: 0.9rem;
}

.app-footer p {
    margin: 0;
}

.feedback-email {
    color: var(--primary, #0066CC);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.feedback-email:hover {
    color: var(--primary-hover, #004C99);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .app-footer {
        font-size: 0.85rem;
        padding: 1rem;
    }
}
