:root {
    --bg-dark: #0a0e14;
    --bg-card: rgba(20, 27, 38, 0.7);
    --gold: #d4af37;
    --gold-bright: #f0c050;
    --text-primary: #f0f2f5;
    --text-secondary: #a0aec0;
    --accent-blue: #3182ce;
    --success: #48bb78;
    --border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.sky-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
    overflow: hidden;
}

/* Subtle dark overlay to ensure text remains perfectly readable */
.sky-background::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 20, 0.6);
    z-index: -1;
}

.flight-path {
    position: absolute;
    display: flex;
    align-items: center;
    z-index: 0;
    opacity: 0.7;
}

.sleek-plane {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

.contrail {
    width: 300px;
    height: 1px;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.4));
    margin-right: 2px;
    filter: blur(1px);
}

.contrail-reverse {
    width: 300px;
    height: 1px;
    background: linear-gradient(to left, rgba(255,255,255,0), rgba(255,255,255,0.4));
    margin-left: 2px;
    filter: blur(1px);
}

/* Path 1: High altitude, slow, left to right */
.path-1 {
    top: 15%;
    left: -20vw;
    animation: fly-1 45s linear infinite;
    transform: rotate(-5deg);
}
.path-1 .sleek-plane { transform: rotate(45deg); }
@keyframes fly-1 {
    0% { transform: translate(0, 0) rotate(-5deg); }
    100% { transform: translate(140vw, -10vh) rotate(-5deg); }
}

/* Path 2: Mid altitude, right to left */
.path-2 {
    top: 40%;
    right: -20vw;
    animation: fly-2 38s linear infinite;
    animation-delay: -15s;
    transform: rotate(5deg);
}
.path-2 .sleek-plane { transform: rotate(-135deg); }
@keyframes fly-2 {
    0% { transform: translate(0, 0) rotate(5deg); }
    100% { transform: translate(-140vw, 15vh) rotate(5deg); }
}

/* Path 3: Top left to bottom right */
.path-3 {
    top: -10vh;
    left: 10vw;
    animation: fly-3 30s linear infinite;
    animation-delay: -8s;
    transform: rotate(35deg);
}
.path-3 .sleek-plane { transform: rotate(45deg); }
@keyframes fly-3 {
    0% { transform: translate(0, 0) rotate(35deg); }
    100% { transform: translate(120vw, 120vh) rotate(35deg); }
}

/* Path 4: Bottom left to top right */
.path-4 {
    top: 80vh;
    left: -20vw;
    animation: fly-4 50s linear infinite;
    animation-delay: -25s;
    transform: rotate(-30deg);
}
.path-4 .sleek-plane { transform: rotate(45deg); }
@keyframes fly-4 {
    0% { transform: translate(0, 0) rotate(-30deg); }
    100% { transform: translate(140vw, -140vh) rotate(-30deg); }
}

header {
    display: flex;
    justify-content: space-between;
    padding: 2rem 5%;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 1px;
}

.logo-img {
    height: 56px;          /* larger so the wide logo reads clearly in the header */
    width: auto;
    display: block;
    /* Lift the logo off the busy sky background and sharpen its edges */
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55)) brightness(1.06);
    transition: filter 0.2s ease;
}
.logo-img:hover {
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6)) brightness(1.12);
}

.gold { color: var(--gold); }
.dim { opacity: 0.5; }

/* ── Auth user menu (header, right side) ─────────────────────────────────────── */
.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
}
.user-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
/* Engineers nav link styled as a button — matches the Logout button so it
   clearly reads as a clickable action, not plain text. */
.nav-link {
    padding: 7px 16px;
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
    background: var(--gold);
    color: #1a1a1a;
}
.logout-btn {
    padding: 7px 16px;
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.logout-btn:hover {
    background: var(--gold);
    color: #1a1a1a;
}

.header-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pulse-icon {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(72, 187, 120, 0); }
    100% { box-shadow: 0 0 0 0 rgba(72, 187, 120, 0); }
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 5%;
}

.hero {
    text-align: center;
    margin-bottom: 4rem;
}

.hero h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 3.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #a0aec0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Keep "Air-Tec" solid gold (matches the Logout button) — the gradient fill
   above otherwise makes the whole heading transparent, hiding the .gold colour */
.hero h1 .gold {
    -webkit-text-fill-color: var(--gold);
    color: var(--gold);
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.upload-container {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 3rem 2rem;
    max-width: 650px;
    margin: 0 auto;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-container:hover, .upload-container.dragover {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.05);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--gold);
}

.upload-box h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-box p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-bright));
    color: #000;
    border: none;
    padding: 0.8rem 2.5rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(212, 175, 55, 0.2);
}

.active-tasks {
    margin-top: 4rem;
    animation: slideUp 0.5s ease-out;
}

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

.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.task-info h4 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.task-id {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.task-badge {
    background: rgba(49, 130, 206, 0.2);
    color: var(--accent-blue);
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.stages {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 2.5rem;
}

.stages::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 1;
}

.stage {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 25%;
}

.stage-dot {
    width: 32px;
    height: 32px;
    background: var(--bg-dark);
    border: 3px solid var(--border);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.stage span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stage.active .stage-dot {
    border-color: var(--gold);
    background: var(--gold);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.stage.active span {
    color: var(--text-primary);
}

.stage.completed .stage-dot {
    border-color: var(--success);
    background: var(--success);
}

.notification-bar {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.email-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.email-status .icon {
    width: 20px;
    height: 20px;
}

.email-status strong {
    color: var(--success);
}

/* =========================================================
   INGEST WARNINGS (shown inside task card after Step 1)
   ========================================================= */

.ingest-warnings {
    flex-direction: column;
    gap: 0.4rem;
    margin: 1rem 0;
}

.ingest-item {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.5;
}

/* Green — page count success confirmation */
.ingest-ok {
    background: rgba(72, 187, 120, 0.08);
    border: 1px solid rgba(72, 187, 120, 0.25);
    color: var(--success);
}

/* Amber — non-blocking warnings (poor quality, blank pages) */
.ingest-warn {
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.25);
    color: #ffc107;
}

/* =========================================================
   MANUAL SELECTOR (Step 2 — shown after file pick)
   ========================================================= */

.manual-selector {
    max-width: 650px;
    margin: 0 auto;
    animation: slideUp 0.4s ease-out;
}

.selector-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    backdrop-filter: blur(10px);
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.selector-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.selector-file-info h4 {
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-all;
}

.manual-dropdown {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 2.5rem 0.85rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    appearance: none;
    /* gold chevron arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d4af37' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    transition: border-color 0.2s ease;
    margin-top: 0.5rem;
}

.manual-dropdown:focus {
    outline: none;
    border-color: var(--gold);
}

.manual-dropdown option {
    background: #1a2232;
}

/* ── Multi-manual checklist (workpack upload) ──────────────────────────────── */
.manual-checklist {
    width: 100%;
    margin-top: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 0;
    background: rgba(255, 255, 255, 0.05);
    max-height: 180px;
    overflow-y: auto;
}

/* Each checkbox row inside the checklist */
.manual-check-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.manual-check-item:hover {
    background: rgba(212, 175, 55, 0.08);
}

/* Style the checkbox to match the gold theme */
.manual-check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Manual selection warning banner ─────────────────────────────────────────
   Shown below the checklist when optional manuals are not selected.
   Hidden by default — app.js controls visibility after auto-detect runs.      */
.manual-warning {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    border-left: 3px solid #c8952a;
    background: rgba(200, 149, 42, 0.08);
    border-radius: 0 8px 8px 0;
    font-size: 0.83rem;
}

.manual-warning-title {
    font-weight: 600;
    color: #c8952a;
    margin-bottom: 0.45rem;
}

.manual-warning-item {
    color: var(--text-primary);
    padding: 0.2rem 0;
    line-height: 1.45;
}

.manual-warning-hint {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Section label inside the grouped manual checklist — Airframe / Engine / Propeller */
.manual-group-header {
    padding: 0.45rem 1rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--gold);
    border-top: 1px solid var(--border);
    margin-top: 0.2rem;
}

/* No top border on the very first group header */
.manual-group-header:first-child {
    border-top: none;
    margin-top: 0;
}

/* Category dropdown used in the manual upload picker */
.category-select {
    padding: 6px 10px;
    background: #161b22;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #f0f6fc;
    font-size: 0.82rem;
    cursor: pointer;
}

.category-select:focus {
    outline: none;
    border-color: var(--gold);
}

/* Ensure options are always readable — browsers inherit page bg otherwise */
.category-select option {
    background: #161b22;
    color: #f0f6fc;
}

/* Hint text shown while loading or when empty */
.checklist-hint {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

#start-btn {
    width: 100%;
    margin-top: 1.5rem;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.btn-ghost:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* =========================================================
   KNOWLEDGE BASE
   ========================================================= */

.knowledge-base {
    margin-top: 5rem;
    animation: slideUp 0.5s ease-out;
}

.kb-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.kb-heading {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    margin-bottom: 0;
}

.kb-upload-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#manual-upload-status {
    font-size: 0.82rem;
    font-weight: 500;
    min-width: 200px;
    text-align: right;
}

.kb-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    overflow-x: auto; /* horizontal scroll on small screens */
}

.kb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.kb-table thead {
    background: rgba(212, 175, 55, 0.08);
    border-bottom: 1px solid var(--border);
}

.kb-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    white-space: nowrap;
}

.kb-table td {
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.kb-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* Truncate very long filenames with an ellipsis; full name visible on hover via title attr */
.kb-filename {
    color: var(--text-primary) !important;
    font-weight: 500;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-empty {
    text-align: center;
    padding: 2.5rem !important;
    color: var(--text-secondary);
    font-style: italic;
}

.kb-action {
    display: inline-block;
    padding: 0.35rem 1rem;
    border: 1px solid var(--gold);
    border-radius: 8px;
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.kb-action:hover {
    background: var(--gold);
    color: #000;
}

/* Action cell holds View + Delete side by side */
.kb-action-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Delete button — superadmin only, rendered inline beside View PDF */
.kb-delete-btn {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid rgba(220, 53, 69, 0.5);
    background: transparent;
    color: #dc3545;
    transition: background 0.2s ease, color 0.2s ease;
}

.kb-delete-btn:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

/* Section group header row — spans all columns, labels each group (Airframe / Engine etc.) */
.kb-group-header-row {
    background: rgba(212, 175, 55, 0.06);
}

.kb-group-header-cell {
    padding: 0.55rem 1.5rem !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold) !important;
    border-top: 1px solid var(--border) !important;
}

/* No top border on the very first group header */
.kb-group-header-row:first-child .kb-group-header-cell {
    border-top: none !important;
}

/* =========================================================
   FOOTER
   ========================================================= */

footer {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* =========================================================
   MODE TOGGLE — Single PDF / Work Pack
   ========================================================= */

.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem auto 1rem;
    max-width: 340px;
}

.mode-btn {
    flex: 1;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: #000;
}

.mode-btn:not(.active):hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* =========================================================
   WORK PACK FILE LIST PREVIEW
   ========================================================= */

.workpack-file-list {
    margin: 0.8rem 0;
    padding: 0.8rem 1rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.wp-summary {
    font-size: 0.78rem;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.wp-file-ul {
    list-style: none;
    padding: 0;
}

.wp-file-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wp-more {
    color: var(--gold);
    font-style: italic;
}


/* =========================================================
   AIRCRAFT AUTO-DETECTION BADGES
   ========================================================= */

.detect-result {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

/* Individual tag pill */
.detect-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
}

/* Green pill — aircraft + manual successfully detected */
.detect-ok {
    background: rgba(72, 187, 120, 0.12);
    border: 1px solid rgba(72, 187, 120, 0.4);
    color: #48bb78;
}

.detect-ok strong {
    color: #fff;
    font-weight: 600;
}

/* Amber pill — not recognised, manual selection required */
.detect-warn {
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold);
}
