/*
Theme Name: Legend Air Portal
Description: Dispatch management.
Version: 2.2 (Scroll & Overflow Fix)
*/

/* ── 1. VARIABLES & CORE SETTINGS ── */
:root {
    --navy: #0a1628;
    --navy-light: #1e3a5f;
    --accent: #2e9afa;
    --gold: #e8a838;
    --gold-soft: #f0c46a;
    --white: #ffffff;
    --off-white: #f4f7fb;
    --gray-light: #e8edf5;
    --gray-mid: #a0aec0;
    --gray-text: #4a5568;
    --border: #dce6f0;
    --success: #2dd4a0;
    --danger: #f56565;
    --warn: #f6ad55;
    --shadow: 0 4px 12px rgba(10, 22, 40, 0.05);
    --shadow-hover: 0 8px 24px rgba(10, 22, 40, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--off-white);
    color: var(--navy);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── 2. LAYOUT ── */
.content-area {
    max-width: 1200px; /* Increased from 900px to fit more columns */
    margin: 40px auto;
    padding: 0 20px;
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    /* FIX: Changed from hidden to visible to allow internal scrolling/growth */
    overflow: visible; 
}

.card-body { padding: 32px; }

/* ── 3. HEADER & NAVIGATION ── */
.main-header {
    background: var(--navy);
    color: var(--white);
    padding: 1.25rem 0;
}

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

.tab-nav {
    background: var(--navy-light);
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 16px 28px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
    background: rgba(255, 255, 255, 0.05);
}

/* ── 4. BRANDED STRIPE LOGIC ── */
.priority-stat { 
    /* Branded Crimson Red from Legend Air Logo */
    border-left: 8px solid #c41e3a !important; 
    background-color: rgba(196, 30, 58, 0.02); 
}

.priority-routine { 
    /* Branded Navy Blue from Header Bar */
    border-left: 8px solid #0a1628 !important; 
    background-color: rgba(10, 22, 40, 0.02);
}

/* ── MEDIUM CARD GRID SYSTEM ── */
#ordersList, #adminOrdersList {
    display: grid;
    /* This creates the side-by-side medium card layout */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); 
    gap: 16px;
}

.order-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px; 
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    min-height: 240px; /* Uniform height for clean grid */
    box-shadow: var(--shadow);
}

.order-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(10, 22, 40, 0.2);
}

/* ── TYPOGRAPHY & SPACING ── */
.order-card h3 {
    font-size: 1.05rem; 
    margin: 0 0 8px 0;
    color: #0a1628; /* Branded Navy */
    font-weight: 700;
    line-height: 1.3;
}

.order-card p {
    font-size: 13px; 
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-text);
}

.order-card p strong {
    font-weight: 600;
    color: #1e3a5f; /* Navy light variant */
}

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

/* ── PDF/ACTION BUTTONS ── */
.print-btn {
    margin-top: auto; /* Pushes button to the bottom of the card */
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    text-align: center;
}

.print-btn:hover {
    background: #0a1628;
    color: white;
    border-color: #0a1628;
}

/* ── 5. ADVANCED FORM COMPONENTS (CF7) ── */
.form-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 25px;
    margin-bottom: 25px;
}

.section-header {
    background: var(--navy);
    color: var(--white);
    margin: -25px -25px 20px -25px;
    padding: 14px 25px;
    font-weight: 700;
    font-size: 15px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.grid-row { display: flex; gap: 20px; margin-bottom: 15px; }
.grid-col { flex: 1; }

.wpcf7-text, .wpcf7-select, .wpcf7-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-size: 16px;
    margin-top: 8px;
    transition: border-color 0.2s;
}

.wpcf7-text:focus { border-color: var(--accent); outline: none; }

.priority-grid span.wpcf7-list-item { display: inline-block; width: 32%; margin: 0; }
.priority-grid label {
    display: block;
    border: 2px solid var(--gray-light);
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
}

.priority-grid input:checked + span {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

/* ── 6. ACCORDIONS (Cut-off Fix) ── */
.accordion-item {
    border: 1px solid var(--border);
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    background: var(--white);
    overflow: hidden; 
    transition: border-color 0.3s ease;
}

.accordion-header {
    background: #f8fafc;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--navy);
    margin: -1px -1px 0 -1px; 
}

.accordion-item.active .accordion-header {
    background: var(--navy);
    color: var(--white);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* Remove vertical padding from here, move it to an inner wrapper */
    padding: 0 25px; 
}

/* Create an inner wrapper feel to prevent cut-offs */
.accordion-content-inner {
    padding: 20px 0 25px 0;
}

.accordion-content .wpcf7-list-item {
    display: block;
    margin: 0 0 12px 0; /* Space between items */
}

/* ── 7. BUTTONS & FORM FEEDBACK ── */
.main-submit, .wpcf7-submit {
    width: 100%;
    background: var(--navy) !important;
    color: var(--gold) !important;
    padding: 18px !important;
    border: none !important;
    border-radius: 50px !important;
    font-weight: 800 !important;
    font-size: 16px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(10, 22, 40, 0.2);
    transition: var(--transition) !important;
}

.main-submit:hover {
    transform: translateY(-2px);
    background: var(--navy-light) !important;
    box-shadow: 0 6px 20px rgba(10, 22, 40, 0.3);
}

/* Response Output (Success/Error Messages) */
.wpcf7-response-output {
    margin: 24px 0 0 0 !important;
    padding: 20px !important;
    border-radius: var(--radius-sm) !important;
    border: 2px solid transparent !important;
    font-weight: 700 !important;
    text-align: center !important;
    font-size: 15px !important;
}

/* Success: Sent Successfully */
.wpcf7-mail-sent-ok {
    background: #ecfdf5 !important;
    border-color: var(--success) !important;
    color: var(--navy) !important;
}

/* Error: Validation or Server Issues */
.wpcf7-validation-errors, 
.wpcf7-mail-sent-ng {
    background: #fff5f5 !important;
    border-color: var(--danger) !important;
    color: var(--navy) !important;
}

/* Remove the default CF7 checkmark/spinner icons if they clash */
span.wpcf7-spinner {
    display: block;
    margin: 10px auto;
}

/* ── 8. RESPONSIVE DESIGN ── */
@media (max-width: 768px) {
    .grid-row { flex-direction: column; gap: 0; }
    .priority-grid span.wpcf7-list-item { width: 100%; margin-bottom: 10px; }
    .checkbox-grid span.wpcf7-list-item { width: 100%; }
    .content-area { margin: 20px auto; }
}

/* ── 9. DISPATCH BOARD ANIMATIONS ── */

/* Pulse for STAT orders */
.priority-stat {
    position: relative;
    border-left: 8px solid var(--danger) !important;
}

.priority-stat::after {
    content: 'URGENT';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    font-weight: 900;
    color: var(--danger);
    animation: statPulse 2s infinite;
}

@keyframes statPulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── 10. STICKY SUBMIT BAR ── */
.submit-wrap {
    position: sticky;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px 0;
    border-top: 1px solid var(--border);
    z-index: 100;
    margin-top: 20px;
}

/* Adjusting the button inside the sticky wrap */
.submit-wrap .wpcf7-submit {
    max-width: 800px;
    margin: 0 auto;
    display: block;
}

/* --- New Status Specific Colors --- */
.status-accepted { color: #2e9afa; background: rgba(46, 154, 250, 0.1); } /* Blue */
.status-in-route { color: #e8a838; background: rgba(232, 168, 56, 0.1); } /* Gold/Orange */
.status-completed { color: #2dd4a0; background: rgba(45, 212, 160, 0.1); } /* Green */
.status-pending { color: #f6ad55; background: rgba(246, 173, 85, 0.1); } /* Warning/Peach */

/* ── COLORED LEFT STRIPES ── */
.order-card {
    position: relative;
    border-left: 8px solid var(--border);
    padding-left: 16px;
    transition: var(--transition);
}

/* Routine → Navy Blue stripe */
.order-card.routine {
    border-left-color: #0a1628 !important;
    background-color: rgba(10, 22, 40, 0.02);
}

/* Urgent & Emergency → Crimson Red stripe (matches your logo) */
.order-card.urgent,
.order-card.emergency {
    border-left-color: #c41e3a !important;
    background-color: rgba(196, 30, 58, 0.03);
}

/* Completed jobs */
.order-card.job-completed,
.order-card.completed {
    border-left-color: #64748b !important;
    background-color: rgba(100, 116, 139, 0.05);
}

/* Flex container for Dispatch & Status */
.dispatch-status-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap; /* allows wrapping on small screens */
}

/* Each field-wrap takes equal width */
.dispatch-status-grid .field-wrap {
    flex: 1 1 0; /* grow, shrink, base width */
    display: flex;
    flex-direction: column; /* label on top, input below */
}

/* Optional: max width for large screens */
@media (min-width: 1024px) {
    .dispatch-status-grid .field-wrap {
        max-width: 33.33%; /* 3 columns equally spaced */
    }
}

/* Mobile: stack vertically */
@media (max-width: 768px) {
    .dispatch-status-grid {
        flex-direction: column;
    }

    .dispatch-status-grid .field-wrap {
        max-width: 100%;
    }
}

.dispatch-status-grid .wpcf7-date {
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-size: 16px;
    width: 100%;
    appearance: none; /* remove default native styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    background: var(--white) url('data:image/svg+xml;charset=US-ASCII,<svg fill="%23647D8B" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 4h-1V2h-2v2H8V2H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"/></svg>') no-repeat right 12px center;
    background-size: 20px 20px;
}

/* Hover / Focus */
.dispatch-status-grid .wpcf7-date:focus {
    border-color: var(--accent);
    outline: none;
}

.filter-pill {
    background: #f0f0f0;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-pill:hover {
    background: #e0e0e0;
}

.filter-pill.active {
    background: #002d5b; /* Legend Air Navy */
    color: white;
}

/* Inventory Filter Pills */
#inventoryFilters {
    padding: 10px 0;
}

.filter-pill {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 18px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    color: #444;
}

.filter-pill:hover {
    background: #f8f9fa;
    border-color: #bbb;
}

.filter-pill.active {
    background: #002d5b; /* Legend Air Navy */
    color: #fff;
    border-color: #002d5b;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#inventoryContainer {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#inventoryContainer table {
    min-width: 600px; /* Forces the table to stay readable on mobile */
}