/* CSS Variables & Theme Definitions */
:root {
    --bg-color: #0B101A;
    --card-bg: #1A2234;
    --card-border: #2A364A;
    --text-primary: #ffffff;
    --text-secondary: #8295AD;
    --text-muted: rgba(130, 149, 173, 0.6);
    
    /* Flight Rules Colors */
    --color-vfr: #22c55e;
    --color-vfr-hover: #16a34a;
    --color-mvfr: #3b82f6;
    --color-ifr: #ef4444;
    --color-lifr: #d946ef;
    
    /* Other Status Colors */
    --color-sunset: #e67e22;
    --color-humidity: #3498db;
    --color-qnh: #9b59b6;
    --color-age: #1abc9c;
    
    --color-primary-orange: #F97316;
    --color-primary-orange-hover: #fb923c;
    
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
    position: relative;
}

/* Background Glow Circles */
.glow-circle {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}
.glow-blue-1 {
    top: -10%;
    left: -5%;
    width: 40rem;
    height: 40rem;
    background: rgba(30, 64, 175, 0.12);
    filter: blur(120px);
}
.glow-blue-2 {
    top: 10%;
    left: 30%;
    width: 30rem;
    height: 30rem;
    background: rgba(56, 189, 248, 0.04);
    filter: blur(120px);
}
.glow-orange {
    bottom: -10%;
    right: -5%;
    width: 45rem;
    height: 45rem;
    background: rgba(249, 115, 22, 0.12);
    filter: blur(150px);
}

/* Loader Styles */
.loader-container, .error-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26, 34, 52, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--card-border);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.error-container h3 {
    margin: 15px 0 10px;
    color: #ff4d4d;
}

.error-container p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.error-container button {
    background: #ff4d4d;
    border: none;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.error-container button:hover {
    background: #e03838;
}

/* Dashboard Layout */
.dashboard-container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 10;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.header h1 {
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 700px;
}

.header-sub {
    margin-top: 6px;
    display: flex;
    gap: 16px;
    font-size: 14px;
}

.active-tag {
    color: var(--text-secondary);
}

.active-tag strong {
    color: var(--text-primary);
    font-weight: 600;
}

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

.time-block {
    text-align: right;
}

.time-value {
    font-size: 22px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

.time-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 2px;
}

/* Main Grid Layout */
.main-grid {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    gap: 16px;
    min-height: 400px;
}

/* Panels Common Style */
.panel-left, .panel-center, .panel-right {
    position: relative;
}

/* Left Panel styling */
.panel-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.temp-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

.temp-icon-container {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.temp-icon-container svg {
    width: 100%;
    height: 100%;
}

.temp-details {
    display: flex;
    flex-direction: column;
}

.temp-main {
    font-size: 36px;
    font-weight: 300;
    line-height: 1;
}

.temp-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.weather-condition {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-primary);
    text-transform: capitalize;
}

.details-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.green { background-color: var(--color-vfr); }
.status-dot.blue { background-color: var(--color-mvfr); }
.status-dot.red { background-color: var(--color-ifr); }
.status-dot.magenta { background-color: var(--color-lifr); }
.status-dot.gray { background-color: var(--text-muted); }

.detail-content {
    display: flex;
    width: 100%;
    justify-content: space-between;
    font-size: 14px;
}

.detail-val {
    font-weight: 500;
}

.detail-lbl {
    color: var(--text-muted);
}

.flight-rule-badge {
    margin-top: auto;
    border-radius: 20px 0 0 20px;
    padding: 14px 24px;
    font-size: 32px;
    font-weight: 600;
    text-align: left;
    color: white;
    width: 110%; /* Overflow slightly to the left or extend */
    margin-left: -5%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    letter-spacing: 1px;
}

.flight-rule-badge.vfr { background-color: var(--color-vfr); }
.flight-rule-badge.mvfr { background-color: var(--color-mvfr); }
.flight-rule-badge.ifr { background-color: var(--color-ifr); }
.flight-rule-badge.lifr { background-color: var(--color-lifr); }

/* Center Panel styling */
.panel-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.compass-wrapper {
    width: 320px;
    height: 320px;
    position: relative;
    margin-bottom: 4px;
}

#compass-svg {
    width: 100%;
    height: 100%;
}

.compass-rim {
    fill: none;
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 8px;
}

.compass-rim-inner {
    fill: none;
    stroke: rgba(255, 255, 255, 0.04);
    stroke-width: 1px;
}

.compass-degree-label {
    fill: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    text-anchor: middle;
    dominant-baseline: middle;
}

.compass-degree-tick {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 1px;
}

.compass-degree-tick.major {
    stroke: rgba(255, 255, 255, 0.45);
    stroke-width: 1.5px;
}

.runway-label {
    fill: white;
    font-size: 11px;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
}

.wind-sector {
    fill: rgba(47, 181, 67, 0.2);
    stroke: var(--color-vfr);
    stroke-width: 1.5px;
}

.wind-arrow-hidden {
    display: none;
}

/* Sub-indicators dials grid */
.sub-indicators {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 440px;
    gap: 8px;
}

.indicator-dial-card {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
    padding: 10px;
}

.dial-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.dial-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 2.2px;
}

.dial-progress {
    fill: none;
    stroke-width: 2.2px;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
}

.color-age { stroke: var(--color-age); }
.color-sunset { stroke: var(--color-sunset); }
.color-humidity { stroke: var(--color-humidity); }
.color-qnh: { stroke: var(--color-qnh); }
.dial-progress.color-qnh { stroke: var(--color-qnh); }

.dial-content {
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.dial-val {
    font-size: 13px;
    font-weight: 600;
}

.dial-lbl {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: capitalize;
    margin-top: 1px;
}

/* Runway Wind specific card overrides */
.runway-wind-card {
    border-radius: 12px;
    aspect-ratio: auto;
    height: auto;
    flex: 1.2;
    padding: 8px;
    justify-content: center;
    border-radius: 8px;
}

.runway-wind-graphic {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.rwy-badge {
    background: #111;
    color: #fff;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 4px;
    border: 1px solid #444;
}

.arrow-container {
    color: var(--text-secondary);
}

.rwy-wind-txt {
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

/* Right Panel styling */
.panel-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
}

.ruler-and-status {
    display: flex;
    gap: 16px;
    flex-grow: 1;
}

/* Altitude Ruler */
.alt-ruler {
    width: 44px;
    position: relative;
    height: 280px;
    align-self: flex-start;
}

.ruler-line {
    position: absolute;
    right: 0;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: rgba(255, 255, 255, 0.2);
}

.ruler-tick {
    position: absolute;
    right: 0;
    width: 8px;
    height: 1px;
    background: rgba(255, 255, 255, 0.4);
}

.ruler-tick span {
    position: absolute;
    right: 14px;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

.ceiling-marker {
    position: absolute;
    right: -2px;
    width: 14px;
    height: 2px;
    background: var(--color-vfr);
    transition: bottom 0.5s ease;
}

.marker-bubble {
    position: absolute;
    right: 20px;
    transform: translateY(-50%);
    background: var(--color-vfr);
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Checklist / Right buttons */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.check-btn {
    width: 100%;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    border: 1px solid var(--card-border);
    background: #111827;
    color: var(--text-secondary);
    cursor: default;
    user-select: none;
    transition: all 0.2s;
}

.check-btn.active {
    background: var(--color-vfr);
    color: white;
    border-color: var(--color-vfr);
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.check-btn.active:hover {
    background: var(--color-vfr-hover);
}

/* Right footer */
.right-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

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

.qr-code {
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    background: white;
    padding: 3px;
}

.qr-url {
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    word-break: break-all;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-main {
    font-size: 14px;
    font-weight: 700;
    color: white;
}

.logo-sub {
    font-size: 10px;
    color: var(--text-muted);
}

/* Bottom Grid Layout */
.footer-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    margin-top: 24px;
}

/* Forecast Panel */
.panel-forecast {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    overflow-x: auto;
}

.forecast-timeline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 320px;
}

.forecast-hour-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.fc-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.fc-badge {
    font-size: 9px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}

.fc-badge.vfr { background: var(--color-vfr); }
.fc-badge.mvfr { background: var(--color-mvfr); }
.fc-badge.ifr { background: var(--color-ifr); }
.fc-badge.lifr { background: var(--color-lifr); }

.fc-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fc-icon svg {
    width: 100%;
    height: 100%;
}

.fc-wind {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* Raw Messages Box styling */
.panel-raw-messages {
    background: #111827;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 130px;
}

.raw-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.raw-messages-list {
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.raw-message-item {
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(26, 34, 52, 0.3);
    border-left: 3px solid var(--card-border);
}

.raw-message-item.latest {
    border-left-color: var(--color-primary-orange);
    background: rgba(249, 115, 22, 0.08);
    color: white;
    font-weight: 500;
}

/* Scrollbars */
.raw-messages-list::-webkit-scrollbar {
    width: 6px;
}
.raw-messages-list::-webkit-scrollbar-track {
    background: transparent;
}
.raw-messages-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.raw-messages-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive Stacking */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }
    .main-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .footer-grid {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 20px;
        white-space: normal;
    }
    .flight-rule-badge {
        width: 100%;
        margin-left: 0;
        border-radius: 12px;
    }
    .compass-wrapper {
        width: 280px;
        height: 280px;
    }
    .alt-ruler {
        height: 220px;
    }
}
