/* Global CSS changes */

button {
    font-family: "Tahoma", sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: 11px;
    box-sizing: border-box;
    border: 1px solid #003c74;
    background: linear-gradient(180deg, #fff, #ecebe5 86%, #d8d0c4);
    box-shadow: none;
    border-radius: 3px;
}

button:active {
    /* Remove the modern movement */
    transform: none; 
    
    /* Invert the gradient to look sunken */
    background: linear-gradient(180deg, #d8d0c4 0%, #ecebe5 14%, #fff 100%);
    
    /* Darken the border to simulate a shadow */
    border-color: #002e5a;
    
    /* Optional: Add the classic XP 'focused/active' dotted inner ring or orange tint */
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Main HTML */

html, body {
    /* Layout: Allow the page to grow while keeping the teal background solid */
    height: auto; 
    min-height: 100%; 
    margin: 0;
    background: #018281; /* Classic Teal Desktop Color */
    
    /* Your Aesthetic Specs (Restored) */
    font-family: "Tahoma", sans-serif;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    font-smooth: never;
    text-rendering: pixelated;
    
    /* Scroll Behavior */
    overflow-x: hidden; 
    overflow-y: auto; /* This ensures the scrollbar is on the edge of the screen, not the table */
}

/* Welcome page */

#startPage {
    display: flex;
    justify-content: center; /* Horizontal centering */
    align-items: center;     /* Vertical centering */
    width: 100vw;
    min-height: 100vh;
}

#welcom-screen-container {
    width: 95%;
    max-width: 500px;
    background-color: #ece9d8;
    color: #222;
    font-weight: 200;
    text-align: left;
    font-size: 14px;
    /* XP Style border */
    border-top-left-radius: 8px;
    border-top-right-radius: 7px;
    box-sizing: border-box;
}

#websiteheader {
    width: 100%;
    height: 30px;

    background: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
    padding: 3px 5px 3px 3px;
    border-top: 1px solid #0831d9;
    border-left: 1px solid #0831d9;
    border-right: 1px solid #001ea0;
    border-top-left-radius: 8px;
    border-top-right-radius: 7px;

    /* font setting */

    color: #fff;
    text-align: left;
    text-shadow: 1px 1px #0f1089;
    font-size: 14px;

    /* Layout */
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;
}

#websitesubheader {
    width: 100%;
    font-size: 12px;
    /* Remove standard padding to allow splash-screen to hit the edges */
    padding: 0; 
    border-left: 1px solid #0052d1;
    border-right: 1px solid #0052d1;
    box-sizing: border-box;
    background-color: #ece9d8;
}

#splash-screen {
    display: flex;
    align-items: center; /* Vertical center */
    justify-content: space-between; /* Pushes image left, text right */
    width: 100%;
    height: 150px; /* Adjust height based on your image size */
    overflow: hidden;
    position: relative;
}

#splash-image {
    flex: 0 0 65%; /* Image takes up 75% of the width */
    height: 100%;
    background-image: url('../media/splash.jpg'); /* Replace with your image path */
    background-size: cover;
    background-position: center;
    
    /* The Fading Mask: Fades the right 25% of the image */
    -webkit-mask-image: linear-gradient(to right, black 70%, transparent 100%);
    mask-image: linear-gradient(to right, black 70%, transparent 100%);
}

#splash-text {
    flex: 1; /* Takes remaining space */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Right justify text content */
    padding-right: 20px;
    
    /* Styling for the text */
    font-size: 25px;
    color: #222; /* Classic Windows XP Dark Blue */
    text-align: left;
    z-index: 2; /* Ensures text stays on top */
    
    /* This allows the text container to overlap the faded image area */
    margin-left: -10%; 
}

/* The instruction text below the splash screen */
.instruction-text {
    padding: 10px 10px 5px 10px;
}

#inputdata-container {
    width: 100%;
    background-color: #ece9d8;
    display: flex; 
    flex-direction: column;
    align-items: center;
    padding-bottom: 20px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 12px;

    /* The container provides the side and bottom blue borders */
    border-left: 1px solid #0052d1;
    border-right: 1px solid #0052d1;
    border-bottom: 1px solid #0052d1;
    box-sizing: border-box;
}

#inputdata {
    max-width: 450px; /* Increased to accommodate the sidebar */
    display: grid;
    grid-template-columns: 200px 1fr; /* Fixed 200px left, flexible right */
    gap: 20px;
    align-items: start;
}

/* Container for the existing entry fields */
.input-main-form {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #aca899;
    padding-right: 15px;
}

/* Sidebar for Open and Manual buttons */
.input-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-left: 15px;
    margin-top: 5px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sidebar-section label {
    margin-top: 0 !important; /* Reset existing label margin */
    color: #222; /* Navy blue label for distinct sections */
}

/* Sidebar Button Styling - Inheriting your global button look */
.sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 6px 8px;
    width: 100px; /* Only as wide as the content */
    cursor: pointer;
    text-align: left;
    white-space: nowrap; /* Prevents text wrapping */
    background: #ece9d8;
    border: none;
}

.sidebar-btn img {
    image-rendering: pixelated; /* Keeps icons sharp like XP */
    flex-shrink: 0;
}

#databaseSelector {
    border-top: 1px solid #aca899;
    padding-top: 10px;
}

@media (max-width: 480px) {
    #inputdata {
        grid-template-columns: 1.2fr 1fr; 
        gap: 10px;
        width: 100%;
        padding: 0 10px;
    }

    .input-sidebar {
        margin-top: 5px;
        margin-left: -10px;
        max-width: 140px;
    }

    .sidebar-section {
        /* Stack buttons vertically but keep them tight, 
           or use 'flex-direction: row' if you want them side-by-side */
        flex-direction: column; 
        gap: 8px;
    }

    .sidebar-btn {
        /* Prevent the buttons from being massive */
        width: 100px; 
        padding: 4px 6px;
        font-size: 11px; /* Slightly smaller text for mobile */
    }
}

#flightschedulebutton {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Avoid oversized text on large screens */
@media (min-width: 768px) {
    #websiteheader {
        font-size: 4vw;
        padding: 30px 40px;
    }
}


/* Input text fields */

#inputdata input[type="text"] {
    width: 165px;
    height: 23px;
    padding: 3px 4px;
    border: 1px solid #7f9db9;
    background-color: #fff;
    box-sizing: border-box;
    font-family: 'Tahoma', monospace;
    font-size: 11px;
}

#inputdata label {
    display: block;
    font-family: 'Tahoma', monospace;
    font-size: 11px;
    margin-top: 4px;
}

#inputdata ::placeholder {
    font-size: 11px;
    color: #99aab9;
}



/* Container alignment */
.radio-group {
    display: flex;
    gap: 15px;
    padding: 5px 0;
}

.radio-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-family: "Pixelated MS Sans Serif", Tahoma, sans-serif;
    font-size: 11px;
    -webkit-font-smoothing: none;
}

/* Specific reset for the radio inputs */
.radio-container input[type="radio"] {
    display: none;
}

/* The Outer Circle */
.radio-label {
    display: flex;
    align-items: center;
    position: relative;
}

.radio-label::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    background: #fff;
    /* The distinctive dark-blue XP outer ring */
    border: 1px solid #003c74; 
    border-radius: 50%;
    box-sizing: border-box;
}

/* The Selected State: Green Pixel Dot */
.radio-container input:checked + .radio-label::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 6px;
    height: 6px;
    /* The classic XP "Success" Green */
    background: #21a121; 
    border-radius: 50%;
    /* Subtle inner-dot shading */
    box-shadow: inset 1px 1px #107c10; 
}

/* Fix text contrast in your subheader */
.radio-label {
    color: #222;
}

/* Loading spinner */

#loader-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    z-index: 1000; color: white;
}

.spinner {
    width: 50px; height: 50px;
    border: 5px solid #333;
    border-top: 5px solid #00a2ed; /* MSFS Blue */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Table page */

#flightSchedule {
    display: block;
    width: 100%;
    height: auto !important; /* Force override any JS-injected heights */
    min-height: 100vh;
    overflow: visible;       /* Ensure it doesn't try to scroll internally */
    color: #222;
    background-color: #e0e0e0;
    border-bottom: 1px solid #0052d1;
}

#roster-header-container {
    display: flex;
    width: 100%;
    align-items: stretch; /* Changed to stretch to help centering the rerun area */
    padding: 10px 10px 10px 10px; 
    box-sizing: border-box;
    position: relative;
    border-top: 1px solid #aca899; 
    box-shadow: inset 0 1px 0 #ffffff;
}

#preamble {
    flex: 1;
    display: flex;
    flex-direction: row; /* Change to row */
    align-items: center; 
    gap: 15px; 
    padding: 2px 0;
}

#xp-fields-container {
    display: flex;
    flex-direction: column; /* Keep the boxes themselves stacked */
    gap: 4px;
}

.xp-field {
    display: flex;
    align-items: center;
}

.xp-label {
    font-family: "Tahoma", sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #222;
    text-transform: uppercase;
    width: 50px;           /* Fixed width ensures the boxes align vertically */
    flex-shrink: 0;
}

.xp-input-box {
    width: 50px;          /* Defined width for the stacked look */
    height: 16px;          /* Slightly more compact */
    background-color: #e0e0e0;
    padding: 0 4px;
    font-size: 12px;
    color: #222;
    display: flex;
    align-items: center;

    /* The Classic Sunken Border Effect */
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-bottom: 1px solid #fff;
    border-right: 1px solid #fff;
    box-shadow: inset 1px 1px 0px #000; 
}

#airline-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px; 
    height: 45px;
    flex-shrink: 0;
}

#airline-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Keeps the look clean on light backgrounds */
    image-rendering: auto; 
}

#rerun-container {
    flex: 0 0 160px;         /* Increased from 120px to 160px for more width */
    display: flex;
    flex-direction: row;     /* Align button and text side-by-side */
    justify-content: flex-start; /* Align to the start of the container */
    align-items: center;     /* Perfectly centers text vertically with button */
    border-left: 1px solid #aca899;
    padding-left: 15px;      /* Space after the vertical divider line */
    margin-left: 10px;
    gap: 10px;               /* Space between the button and the text */
}

#rerunButton {
    width: 28px; 
    height: 28px;
    flex-shrink: 0;          /* Prevents the button from squishing */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
}

#rerunText {
    font-size: 12px;         /* Slightly larger for readability */
    color: #222;
    white-space: nowrap;     /* Keeps the text on one line */
    line-height: 1;          /* Helps with vertical centering */
}

/* Briefcase Styling - The Toolbar Container */
#briefcase-area {
    background: #e0e0e0; /* Match the dark teal in your diagram */
    padding: 5px;
    
    /* Force everything into one horizontal line */
    display: flex;
    flex-direction: row; 
    align-items: center;
    gap: 6px;
}

/* Ensure the internal row divs don't break the line */
.briefcase-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* 1. SAVE BUTTON (First on the left) */
#saveCurrentTrip {
    order: -1; /* Forces it to the absolute start */
    width: 32px;
    height: 32px;
    background-color: #c9c8c8;
    border: 1px solid #afafaf;
}

.select-wrapper {
    width: 150px;      /* This is your visual 'window' */
    overflow: hidden;  /* This cuts off the excess from the select inside */
    position: relative;
    display: inline-block;
    vertical-align: middle;
    border: none;      /* Ensure no double borders */
}

#tripSelect {
    width: 180px;      /* WE MAKE THIS WIDER THAN THE PARENT */
    height: 23px;
    box-sizing: border-box;
    
    /* This ensures the text stays left-aligned */
    padding: 0 40px 0 4px; 

    /* Your existing aesthetic styles */
    color: #000;
    font-family: 'MS Gothic', monospace;
    font-size: 11px;
    background-color: #fff;
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-bottom: 1px solid #fff;
    border-right: 1px solid #fff;
    box-shadow: inset 1px 1px 0px #000, inset -1px -1px 0px #c0c0c0;

    appearance: none;
    -webkit-appearance: none;
    
    /* Move the custom arrow further left so it's not cut off by the wrapper */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18'%3E%3Crect width='18' height='18' fill='%23d4d0c8'/%3E%3Cpath d='M5 8h8l-4 4z' fill='black'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 30px center; /* Adjusted to 30px from right */
    background-size: 18px 100%;
}

/* Ensure the popup options don't try to inherit weird spacing */
#tripSelect option {
    width: 180px;
    background-color: #fff;
    color: #222;
}

/* 3. ACTION BUTTONS (The Grid) */
.buttons-grid {
    display: flex; /* Switch from grid to flex for single row */
    gap: 4px;
}

#briefcase-area button {
    width: 32px;
    height: 32px;
    background: #e0e0e0;
    background-color: #e0e0e0;
    border: none;
    border-right: 1px solid #aca899; 
    font-size: 9px;
    cursor: pointer;
    flex-shrink: 0; /* Prevent buttons from squishing */
    border-radius: 0;
}

/* DEL Button Icon Style */
#deleteSelectedTrip {
    border-right: none;
}

/* Table Styles */

.table-container {
    width: 100%;
    overflow-x: auto; 
    overflow-y: hidden; /* Confirms we only want horizontal scrolling here */
    display: block;
    height: auto !important;
    flex: none;
    -webkit-overflow-scrolling: touch; 
    background-color: #fff;
    border: 1px solid #7f9db9; 
    box-sizing: border-box;
    max-height: none !important;
}

#rosterTable {
    /* Layout Fixes */
    width: 100%;
    min-width: 1150px;
    height: auto !important;
    table-layout: auto;
    flex: none; /* Changed from flex: 1 to prevent height clamping */

    /* Your Original Aesthetic Specifications */
    border-collapse: separate; 
    border-spacing: 0; 
    margin: 0;
    font-family: 'Tahoma', sans-serif; 
    font-size: 11px;
    color: #000;
    background-color: #fff;
}

#rosterTable thead th { 
    position: sticky; 
    top: 0; 
    z-index: 10;
    /* Classic XP Column Header Gradient */
    background: linear-gradient(to bottom, #f9f8f4 0%, #ece9d8 100%);
    color: #000;
    font-weight: normal;
    padding: 4px 6px;
    border-right: 1px solid #aca899;
    border-bottom: 1px solid #aca899;
    text-align: center;
    white-space: nowrap;
    /* Bevel effect to make headers look like buttons */
    box-shadow: inset 1px 1px 0px #fff;
}

#rosterTable td {
    border-right: 1px solid #d4d0c8;
    border-bottom: 1px solid #d4d0c8;
    padding: 4px 8px;
    text-align: center;
    white-space: nowrap;
}

/* Zebra Striping: Subtle blue-gray for Enterprise lists */
#rosterTable tbody tr:nth-child(even) {
    background-color: #f1f3f6;
}

/* Day Column: Styled like a vertical header */
#rosterTable td:first-child {
    font-weight: bold;
    background-color: #ece9d8;
    color: #000;
    border-left: 1px solid #aca899;
}

/* Flight Data Highlighting */
#rosterTable td:nth-child(3) { /* Flight Number */
    font-weight: bold;
    color: #000080; /* Navy Blue */
}

#rosterTable td:nth-child(5), #rosterTable td:nth-child(6) { /* ICAO Codes */
    font-family: 'Lucida Console', Monaco, monospace;
    font-weight: bold;
    color: #a00000; /* Dark Red */
}

#closeButton {
    padding-left: 10px;
    padding-top:  15px;
}

/* Prevent iOS from zooming in on input (happens if font < 16px) */
.editable-cell {
    background-color: #fafafa;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
    color: #21a121 !important; /* Green for user-entered data */
}

/* Visual cue for touch */
.editable-cell:active {
    background-color: #e3f2fd;
}

/* Styling for the thick RED day-break border */
.day-break-row td {
    border-bottom: 2px solid #003c74 !important;
}

/* Dashed line for equipment change */
.equip-change-row td {
    /* We apply this to the TOP of the current row */
    border-top: 2px dashed #943a3a !important;
}

/* Make sure links are easy to hit */
.simbrief-link {
    display: block;
    padding: 10px;
    margin: -10px;
    color:#943a3a;
}

/* Alert popup */

#modalOverlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 9999; /* Ensure it is above the table and header */
}

#customModal {
    background-color: #ece9d8;
    width: 90%;
    max-width: 320px;
    border-left: 1px solid #0052d1;
    border-right: 1px solid #0052d1;
    border-bottom: 1px solid #0052d1;
    border-radius: 5px 5px 0 0;
    box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
    overflow: hidden; /* Clips the gradient header correctly */
}

#modalTitle {
    /* Iconic Luna Blue Gradient Title Bar */
    background: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
    color: #fff;
    font-size: 13px;
    font-weight: lighter;
    margin: 0;
    font-family: "Tahoma", sans-serif;
    text-shadow: 1px 1px #003399;
}

.modal-header {
    background: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
    color: #fff;
    font-size: 13px;
    font-weight: lighter;
    padding: 6px 10px;
    margin: 0;
    font-family: "Tahoma", sans-serif;
    text-shadow: 1px 1px #003399;
}

#modalMessage {
    background-color: #ece9d8;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: left;
    font-size: 12px;
    padding-left: 15px;
}

.modal-buttons {
    background-color: #ece9d8;
    padding: 0 15px 15px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-hidden {
    display: none !important;
}

/* Button Overrides for Dialog Consistency */
#modalConfirm, #modalCancel {
    min-width: 75px;
    box-shadow: none;
}

#modalCancel {
    color: #000;
    border-color: #003c74;
}

#notificationOverlay {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.2); /* Lighter dim so you can see the modal below */
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 10000; /* Higher than manualEntryOverlay */
}

#notificationModal {
    background-color: #ece9d8;
    border: 1px solid #0052d1;
    border-radius: 5px 5px 0 0;
    box-shadow: 2px 2px 15px rgba(0,0,0,0.4);
    overflow: hidden;
}

/* Ensure the OK button in the footer is centered for simple alerts */
#notificationOverlay .modal-footer {
    display: flex;
    justify-content: center;
}

/* 1. Reuse the Modal Overlay & Window Styles */
#manualEntryOverlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
}

#manualEntryContent {
    background-color: #ece9d8;
    width: 90%;
    max-width: 400px; /* Slightly wider than the alert for the textarea */
    border-left: 1px solid #0052d1;
    border-right: 1px solid #0052d1;
    border-bottom: 1px solid #0052d1;
    border-radius: 5px 5px 0 0;
    box-shadow: 4px 4px 12px rgba(0,0,0,0.5);
    padding: 0;
    overflow: hidden;
}



/* 2. Style the Header (Matches #modalTitle / #websiteheader) */
#manualHeader {
    background: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
    color: #fff;
    font-size: 13px;
    font-weight: lighter;
    padding: 6px 10px;
    margin: 0;
    font-family: "Tahoma", sans-serif;
    text-shadow: 1px 1px #003399;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 3. Style the Textarea (Matches your input-box "Sunken" effect) */
#csvTextArea {
    width: 100%;
    height: 150px;
    background-color: #fff;
    padding: 5px;
    font-family: 'Lucida Console', Monaco, monospace; /* Monospace for CSV columns */
    font-size: 11px;
    box-sizing: border-box;
    resize: none;
    outline: none;
    
    /* The Classic Sunken Border Effect used in your xp-input-box */
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-bottom: 1px solid #fff;
    border-right: 1px solid #fff;
    box-shadow: inset 1px 1px 0px #000; 
}

/* 4. Modal Body and Buttons */
.manual-body {
    padding: 15px;
    background-color: #ece9d8;
}

.manual-footer {
    padding: 10px 15px 15px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background-color: #ece9d8;
}

/* Print / PDF Formatting */
@media print {
    /* 1. Reset containers so they don't clip the table */
    html, body, #app, #flightSchedule {
        overflow: visible !important;
        height: auto !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .table-container {
        overflow: visible !important; /* This is the key fix */
        display: block !important;
        border: none !important;
        box-shadow: none !important;
    }

    #rosterTable {
        table-layout: auto !important;
        width: 100% !important;
        min-width: 100% !important; /* Force it to fit page width */
        font-size: 8pt !important; /* Shrink font slightly for PDF fit */
    }

    /* 2. Hide UI elements */
    #startPage, #loader-overlay, #briefcase-area, #rerun-container, #closethisflighttrip, h1 {
        display: none !important;
    }

    /* 3. Column adjustments for PDF */
    /* If the table is still too wide, we can hide less important columns for PDF only */
    #rosterTable th:nth-child(7), #rosterTable td:nth-child(7), /* Dep Gate */
    #rosterTable th:nth-child(8), #rosterTable td:nth-child(8)  /* Arr Gate */ {
        display: none; 
    }
}