/* =================== GLOBAL STYLES =================== */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: white;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    display: flex;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

#app {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    background-color: white; /* Border color*/
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
}

/* =================== TYPOGRAPHY =================== */

label_h1 {
    display: block;
    font-weight: bold;
    margin-top: 12px;
    margin-bottom: 6px;
    padding: 10px;
    color: #2a3f54;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

label_h2 {
    display: block;
    font-weight: bold;
    margin-top: 6px;
    margin-bottom: 6px;
    padding: 1px;
    color: #2a3f54;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

label {
    display: block;
    font-weight: normal;
    padding: 3px;
    color: #030506;
    font-size: 14px;
    text-align: center;
}

h1 {
    text-align: center;
}

/* =================== MEDIA QUERIES =================== */

@media (min-width: 768px) {
    html,
    body {
        padding: 0 20px;
        margin: 0 auto;
        align-items: center;
        background-color: #f0f2f6;
        max-width: 768px;
    }

    #app {
        max-width: 390px;
        height: auto;
        min-height: 600px;
        max-height: 90vh;
        border-radius: 8px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        padding: 10px;
    }

    .tab {
        position: relative;
        border-radius: 8px 8px 0 0;
        top: 0;
        z-index: 100;
    }
}

@media (max-width: 768px) {
    body {
        max-width: 768px;
    }
}

@media (hover: none) {
    .map-controls button {
        padding: 8px 12px;
    }
}

/* =================== TABS =================== */

.tab {
    display: flex;
    justify-content: space-between;
    /*background: linear-gradient(90deg, #0a3d6b 0%, #1565a8 100%);*/
    background: linear-gradient(0deg, white 0%, gray 100%);
    border-radius: 8px;
    color: #333333;
    position: sticky;
    top: env(safe-area-inset-top);
    overflow: hidden;
    padding: 0 1px;
    height: 56px !important;
    min-height: 56px;
    flex-shrink: 0;
    z-index: 1000;
}

.tab button {
    flex: 1 1 0;
    max-width: 100%;
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0 12px;
    transition: 0.3s;
    font-weight: bold;
    border-radius: 8px;
    margin: 0 1px;
    height: 100% !important;
    min-height: 56px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: inherit;
}

.tab button:hover {
    background-color: #e8eaed;
}

.tab button.active {
    background-color: transparent;
    box-shadow: inset 0 -4px 0 rgba(255,255,255,0.12);
    position: relative;
    z-index: 1;
}

.tabcontent {
    display: none;
    padding: 10px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* =================== BUTTONS & INPUTS =================== */

.button-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 8px 0;
    width: 100%;
    box-sizing: border-box;
}

.button-row select,
.button-row input[type="text"],
.button-row button {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    background-color: #f0f2f6;
    color: #333;
    transition: background 0.2s;
    min-width: 0;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.button-row button:hover,
.button-row select:hover,
.button-row input[type="text"]:hover {
    background-color: #e8eaed;
}

.button-row button:only-child {
    flex: 1;
    min-width: auto;
    max-width: none;
}

input[type="range"],
button,
input[type="text"] {
    width: 100%;
    margin: 8px 0;
    border: none;
    border-radius: 8px;
    padding: 10px;
    background-color: #f0f2f6;
    color: #333;
    transition: background 0.2s;
    font-size: 14px;
}

input[type="range"]:hover,
button:hover,
input[type="text"]:hover {
    background-color: #e8eaed;
}

input[type="number"] {
    width: 100%;
    padding: 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
}

input[type="number"]:focus {
    border-color: #4a90e2;
    background: #f5f9ff;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    outline: none;
}

input[type="number"]:disabled {
    background: #fafafa;
    color: #777;
}

.button-style {
    font-size: 12px;
    margin: 4px 0;
    text-align: center;
    z-index: 1;
    background-color: #e0e0e0; /* light gray */
    border: 1px solid #333333;
    color: #000; /* black text */
    cursor: pointer;
}

.button-style:hover {
    background-color: #bdbdbd; /* hovering over gray */
    color: #000; /* black text */
    border: 1px solid #333333;
    box-shadow: 0 6px 18px rgba(42, 63, 84, 0.12);
    transform: translateY(-2px);
}

/* =================== LOGO & IMAGE CONTAINERS =================== */

.logo-container {
    position: relative;
    text-align: center;
    margin: 0px;
    margin-top: 10px;
    border-radius: 5px;
    overflow: visible;
    min-height: 80px;
    padding-bottom: 0px;
}

.logo-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.2s;
    max-height: calc(100vh - 220px);
    border-radius: 10px;
    z-index: 0;
}

.logo-container img:hover {
    transform: scale(1.05);
}

.coffee-container {
    text-align: center;
    margin: 30px 0;
    border-radius: 10px;
    overflow: hidden;
}

.coffee-container img {
    max-width: 50%;
    height: auto;
    display: block;
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.2s;
}

.coffee-container img:hover {
    transform: scale(1.05);
}

/* =================== CANVAS OVERLAYS =================== */

.flare-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    border-radius: 10px;
}

.fog-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    border-radius: 10px;
}

.cloud-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    border-radius: 10px;
}

.snow-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    border-radius: 10px;
}

.dark-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 6;
    border-radius: 10px;
}

.rain-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 7;
    border-radius: 10px;
}

.controls-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    inset: 0;
    pointer-events: auto;
    z-index: 8;
    border-radius: 10px;
}

.cloudplot-canvas {
    z-index: 0;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08); /* optional for a soft shadow */
}

/* =================== UTILITY CLASSES =================== */

.warning {
    font-size: 12px;
    color: orange;
    margin: 4px 0;
    text-align: center;
}

.info-blue {
    font-size: 13px;
    font-weight: 400;
    color: #005082;
    margin: 4px 0;
    text-align: center;
}

.info-gray {
    font-size: 10px;
    font-weight: 400;
    color: grey;
    margin: 4px 0;
    text-align: center;
}

.info {
    font-size: 14px;
    color: grey;
    margin: 4px 0;
    text-align: center;
}

.disclaimer {
    font-size: 12px;
    color: red;
    margin: 4px 0;
    text-align: center;
}

.version {
    font-size: 8px;
    color: gray;
    margin: 4px 0;
    text-align: right;
}

.divider {
    height: 1px;
    background: #dcdcdc;
    margin: 16px 0;
}

.border-round-eged {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 8px 6px;
    border: 2px solid white;
    margin: 8px 0;
}

.border-round-eged-logo {
    background-color: transparent;
    border-color: transparent;
    border-radius: 8px;
    padding: 8px 6px;
    border: 2px solid white;
    margin: 8px 0;
}

/* =================== SPINNER =================== */

.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-radius: 50%;
    border-top: 6px solid #3498db;
    animation: spin 1s linear infinite;
}

.spinner-text {
    color: white;
    font-size: 14px;
    margin-top: 15px;
    text-align: center;
    white-space: nowrap;
}

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

/* =================== MAP STYLES =================== */

#map-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin: 20px auto;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.mobile-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    z-index: 9990;
    background: #000;
}

#route-map {
    height: 100%;
    width: 100%;
    border-radius: 4px;
    background: #fff;
}

.leaflet-control-container .leaflet-top {
    z-index: 1000;
}

.map-controls {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    user-select: none;
    touch-action: manipulation;
    text-align: center;
    margin-bottom: 10px;
}

.map-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.map-controls input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.map-controls button,
.map-controls select {
    padding: 5px 10px;
    margin: 0 5px;
    min-width: 32px;
    min-height: 32px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.map-controls button:active {
    background-color: #eee;
}

#fullscreen-btn {
    position: fixed !important;
    top: env(safe-area-inset-top, 10px);
    right: 10px;
    z-index: 99999 !important;
    pointer-events: auto;
}

body:not(.mobile-fullscreen) #fullscreen-btn {
    position: absolute !important;
    top: 10px;
    right: 10px;
}

#fullscreen-btn:hover {
    background-color: #f0f0f0;
}

#fullscreen-btn svg {
    width: 24px;
    height: 24px;
    margin: 8px;
    fill: #333;
    transition: opacity 0.2s ease-in-out;
}

#fullscreen-btn .fullscreen-exit {
    display: none;
}

body.no-scroll {
    overflow: hidden;
    touch-action: none;
}

body.mobile-fullscreen #bottom-container,
body.mobile-fullscreen #bottom-buttons,
body.mobile-fullscreen .output-box {
    display: none !important;
}

/* =================== COLLAPSIBLE SECTIONS =================== */

.collapsible {
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin: 8px 0;
    overflow: hidden;
    background: #f5f5f5;
}

.collapsible:hover {
    border-color: #b0b0b0;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.collapsible-header {
    padding: 10px 14px;
    background: #e9e9e9;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.collapsible-header::after {
    content: "▼";
    font-size: 10px;
    transition: transform 0.2s;
}

.collapsible.open .collapsible-header::after {
    transform: rotate(-180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
    padding: 0 14px;
    background: #f5f5f5;
}

.collapsible.open .collapsible-content {
    padding: 10px 14px;
}

/* =================== GRID LAYOUTS =================== */

.wind-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
    margin-top: 10px;
    border-radius: 8px;
}

.input-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.wind-grid_3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
    border-radius: 8px;
}

.grid-one-third-two-thirds {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    margin-top: 10px;
    border-radius: 8px;
}

.grid-two-thirds-one-third {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    margin-top: 10px;
    border-radius: 8px;
}

.grid-middle-small {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
    border-radius: 8px;
}

.grid-middle-small > .tile {
    grid-column: 2;
    justify-self: center;
    align-self: center;
    border-radius: 8px;
}

/* =================== TILES =================== */

.tile {
    background: white;
    border: 1px solid #dcdcdc;
    border-radius: 14px;
    padding: 12px 10px;
    text-align: center;
    font-size: 16px;
    line-height: 1.2;
    position: relative;
    overflow: hidden;
}

.tile:hover {
    border-color: #b0b0b0;
    background: #fafafa;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 🔧 FIXED: Tile value with proper background */
.tile-value {
    width: 100%;
    box-sizing: border-box;
    font-size: 22px;
    text-align: center;
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
    z-index: 5;
    border-radius: 4px;
    border: none;
    padding: 4px 8px;
}

/* 🔧 FIXED: State classes for JavaScript control */
.tile-value.error-state {
    background-color: #ffebee !important;
}

.tile-value.normal-state {
    background-color: rgb(240, 242, 246) !important;
}

.tile-value.transparent-state {
    background-color: transparent !important;
}

.tile-label {
    font-size: 11px;
    color: #666;
    font-weight: 400;
    text-align: center;
    border-radius: 8px;
}

.tile-value-dropdown {
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    color: #333;
    background: #fff;
    text-align: left;
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
    padding: 8px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    outline: #f5f5f5;
    transition: all 0.2s ease;
    cursor: pointer;
}

.tile-value-dropdown:hover {
    border-color: #b0b0b0;
    background: #f5f9ff;
}

.tile-value-dropdown:focus {
    border-color: #4a90e2;
    background: #f5f9ff;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* =================== WEIGHT & BALANCE =================== */

.weight-card-header {
    font-weight: 500;
    font-size: 13px;
    color: #333;
    margin-bottom: 10px;
}

.weight-card {
    background: white;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.input-label {
    font-size: 11px;
    color: #777;
    margin-bottom: 4px;
    display: block;
}

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

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 20px 0 12px 0;
}

.coordinate-label {
    font-size: 12px;
    color: #777;
    text-align: center;
    margin-bottom: 4px;
}

/* =================== FLIGHT CARD =================== */

.flight-card {
    background: linear-gradient(to bottom, #e8e8e8 0%, #d5d5d5 100%);
    border-radius: 8px;
    padding: 20px;
    max-width: 500px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid white;
}

.route-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.airport {
    flex: 1;
    text-align: center;
    margin: 1px;
}

.airport-code {
    font-size: 48px;
    font-weight: bold;
    color: #2c2c2c;
    margin-bottom: 5px;
    margin: 1px;
}

.airport-name {
    font-size: 14px;
    color: #2c2c2c;
    font-weight: 500;
    margin-bottom: 3px;
}

.plane-icon {
    flex-shrink: 0;
    margin: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.plane-icon:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

.plane-icon:active {
    transform: scale(0.95);
    transform: rotate(90deg);
}

.plane-icon svg {
    width: 40px;
    height: 40px;
    fill: #00a1de;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.schedule-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.schedule-item {
    text-align: center;
}

.schedule-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    margin-top: 35px;
    margin-bottom: 5px;
    font-weight: 500;
    text-align: center;
}

.divider-general-section {
    height: 2px;
    background: #b8b8b8;
    margin: 15px 0;
    position: relative;
}

.divider-plane {
    position: absolute;
    top: 50%;
    left: 20%;
    transform: translate(-50%, -50%) rotate(90deg);
    width: 32px;
    height: 32px;
    background: linear-gradient(to bottom, #e8e8e8 0%, #d5d5d5 100%);
    padding: 4px;
    border-radius: 50%;
}

.distance-section {
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.distance-info {
    display: flex;
    justify-content: space-between;
    flex: 1;
    font-size: 13px;
    color: #666;
}

.clock-input {
    font-size: 26px;
    font-weight: bold;
    font-family: system-ui, -apple-system, Segoe UI, Roboto;
    text-align: center;
    background-color: transparent;
    padding: 12px;
    border-radius: 10px;
    border: transparent;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.clock-input::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: textfield;
    appearance: textfield;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.info-item {
    flex: 1;
}

.aircraft-value {
    font-size: 16px;
    color: #2c2c2c;
    font-weight: 600;
    margin-bottom: 15px;
    text-align: left;
}

.aircraft {
    display: grid;
    grid-template-rows: auto 1fr;
}

.aircraft .tile-label {
    align-self: start;
    font-weight: 500;
}

.aircraft .tile-value {
    align-self: center;
}

.flight-card-row {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.flight-card-icon {
    position: relative;
    width: 15%;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flight-card-content {
    width: 85%;
    padding-left: 12px;
}

.plane-small {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    transform: rotate(90deg);
}

.plane-small:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
    transform: rotate(90deg);
}

.plane-small:active {
    transform: scale(0.95);
}

.plane-small svg {
    width: 36px;
    height: 36px;
    fill: #00a1de;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* =================== METAR STYLES =================== */

.metar-station-icon {
    background: transparent;
    border: none;
}

.metar-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
}

.metar-popup .leaflet-popup-content {
    margin: 10px;
    min-width: 300px;
}

/* =================== GENERAL TAB =================== */

#General {
    display: flex;
    flex-direction: column;
    padding-bottom: 10px;
    box-sizing: border-box;
    position: relative;
}

/* =================== FLASHCARDS =================== */

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns */
  grid-template-rows: repeat(2, 1fr);    /* 2 rows */
  gap: 0;                                /* gap handled by borders */
  width: 600px;                           /* adjust as needed */
  border: 1px solid #f5f5f5;                /* outer border */
}

.cell {
  border-right: 1px solid #f5f5f5;   /* vertical line */
  border-bottom: 1px solid #f5f5f5;  /* horizontal line */
  padding: 20px;
  text-align: center;
  box-sizing: border-box;         /* include border in cell size */
}

/* Remove extra borders on last row and last column */
.grid-container .cell:nth-child(3),
.grid-container .cell:nth-child(6) {
  border-right: none;
}

.grid-container .cell:nth-child(n+4) {
  border-bottom: none;
}

.summary-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
    margin-top: 8px;
}

/* On smaller screens, collapse to 2 columns */
@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
