/* ==========================================
   RESET / BASE
========================================== */

* {
    box-sizing: border-box;
}

:root {
    --ink: #12172b;
    --muted: #6b7488;
    --faint: #98a2b8;
    --line: #e9ecf5;
    --surface: #ffffff;
    --canvas: #f3f4fb;
    --brand-1: #4338ca;
    --brand-2: #6d28d9;
    --brand-3: #2563eb;
    --accent: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(18, 23, 43, 0.06);
    --shadow-md: 0 8px 24px -8px rgba(18, 23, 43, 0.18);
    --shadow-lg: 0 24px 48px -12px rgba(67, 56, 202, 0.28);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #eef0fa;
        --muted: #9aa3bd;
        --faint: #6b7390;
        --line: #262c47;
        --surface: #171b30;
        --canvas: #0e1122;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.55);
        --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
    }
}

body {
    margin: 0;
    background: var(--canvas);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.bg-decor {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(600px 400px at 15% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
        radial-gradient(500px 380px at 110% 10%, rgba(236, 72, 153, 0.12), transparent 60%),
        radial-gradient(700px 500px at 50% 120%, rgba(37, 99, 235, 0.10), transparent 60%),
        var(--canvas);
}

.app {
    max-width: 720px;
    margin: 0 auto;
    min-height: 100vh;
    background: transparent;
}

@media (min-width: 760px) {
    .app {
        margin: 20px auto;
        min-height: calc(100vh - 40px);
        border-radius: 28px;
        overflow: hidden;
        box-shadow: var(--shadow-lg);
    }
}


/* ==========================================
   HEADER
========================================== */

.app-header {
    position: relative;
    padding: 26px 20px 22px;
    background:
        radial-gradient(420px 220px at 90% -20%, rgba(255, 255, 255, 0.18), transparent 60%),
        linear-gradient(135deg, var(--brand-1), var(--brand-2) 55%, var(--brand-3));
    color: #fff;
    overflow: hidden;
}

.app-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(280px 160px at 15% 120%, rgba(255, 255, 255, 0.14), transparent 65%);
    pointer-events: none;
}

.app-header-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    position: relative;
}

.app-header-icon {
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    border-radius: 16px;
    background: linear-gradient(155deg, #fbbf24, #f59e0b);
    box-shadow: 0 8px 18px -4px rgba(245, 158, 11, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.app-header-text h1 {
    margin: 0;
    font-family: "Sora", "Inter", sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.app-header-text p {
    margin: 3px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
}

.stat-chips {
    display: flex;
    gap: 10px;
    position: relative;
}

.stat-chip {
    flex: 1;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-chip-value {
    font-family: "Sora", "Inter", sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.stat-chip-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.75);
}

.stat-chip-accent .stat-chip-value {
    color: #fde68a;
}


/* ==========================================
   BODY / LAYOUT
========================================== */

.app-body {
    padding: 18px 16px 28px;
}


/* ==========================================
   STICKY TOOLBAR
========================================== */

.sticky-toolbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--canvas);
    padding-top: 4px;
    margin: -4px -16px 0;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 4px;
}


/* ==========================================
   TOOLBAR (SEARCH + DOWNLOAD)
========================================== */

.toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, 0.12), var(--shadow-sm);
}

.search-icon {
    color: var(--faint);
    display: flex;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    background: transparent;
    color: var(--ink);
}

.search-box input::placeholder {
    color: var(--faint);
}

.search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--canvas);
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.search-clear:hover {
    background: #fee2e2;
    color: var(--danger);
}

.search-box.has-value .search-clear {
    display: flex;
}


/* ==========================================
   DOWNLOAD BUTTON
========================================== */

.download-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 14px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px -8px rgba(22, 163, 74, 0.55);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px -8px rgba(22, 163, 74, 0.6);
}

.download-btn:active {
    transform: translateY(0);
}


/* ==========================================
   DOWNLOAD BY LOADED DATE
========================================== */

.loaded-download {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.loaded-download-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
}

.loaded-download-label svg {
    color: var(--brand-1);
    flex: 0 0 auto;
}

.loaded-download-controls {
    display: flex;
    gap: 8px;
}

.loaded-download-controls input[type="date"] {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 10px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--canvas);
}

.loaded-download-controls button {
    flex: 0 0 auto;
    border: none;
    border-radius: 10px;
    padding: 9px 18px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.loaded-download-controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px -6px rgba(67, 56, 202, 0.45);
}

@media (min-width: 560px) {
    .loaded-download {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .loaded-download-controls {
        flex: 0 0 auto;
    }
    .loaded-download-controls input[type="date"] {
        flex: 0 0 auto;
    }
}


/* ==========================================
   FILTER DROPDOWN
========================================== */

.filter-dropdown {
    position: relative;
    margin-bottom: 18px;
}

.filter-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 12px 14px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.filter-dropdown-toggle:hover {
    border-color: #c7cef0;
}

.filter-dropdown.open .filter-dropdown-toggle {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, 0.12), var(--shadow-sm);
}

.filter-dropdown-icon {
    display: flex;
    color: var(--brand-1);
    flex: 0 0 auto;
}

#filterDropdownLabel {
    flex: 1;
    text-align: left;
}

.filter-dropdown-chevron {
    flex: 0 0 auto;
    color: var(--faint);
    transition: transform 0.18s ease;
}

.filter-dropdown.open .filter-dropdown-chevron {
    transform: rotate(180deg);
}

.filter-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 2px;
}

.filter-dropdown.open .filter-dropdown-menu {
    display: flex;
}

.filter-option {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 10px 12px;
    border-radius: 9px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.filter-option:hover {
    background: var(--canvas);
    color: var(--ink);
}

.filter-option.active {
    background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
    color: #fff;
}


/* ==========================================
   RESULT LIST / CARDS
========================================== */

.result-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    color: var(--faint);
    padding: 56px 20px;
    font-size: 14px;
}

.empty-state-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    box-shadow: var(--shadow-sm);
}

.load-more-btn {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--brand-1);
    padding: 13px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.load-more-btn:hover {
    background: var(--canvas);
    transform: translateY(-1px);
}

.load-more-btn:active {
    transform: translateY(0) scale(0.99);
}

.truck-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 17px 17px 17px 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
    animation: card-in 0.35s ease both;
}

.truck-card:active {
    transform: scale(0.985);
}

.truck-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--brand-1), var(--brand-3));
    opacity: 0.7;
}

.truck-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #dfe3f5;
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.truck-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 4px;
}

.truck-no {
    font-family: "Sora", "Inter", sans-serif;
    font-size: 19px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.trailer-no {
    font-size: 13px;
    color: var(--faint);
    margin-bottom: 12px;
}

.truck-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px 10px;
    padding-top: 13px;
    border-top: 1px dashed var(--line);
    margin-bottom: 12px;
}

.field-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--faint);
    text-transform: uppercase;
    margin-bottom: 3px;
}

.field-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.gatepass-expired {
    color: var(--danger);
}

.gatepass-valid {
    color: var(--success);
}

.truck-card-hint {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--brand-1);
    text-align: center;
    padding-top: 11px;
    margin-top: 2px;
    border-top: 1px solid var(--line);
    letter-spacing: 0.01em;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 6px 13px;
    border-radius: 999px;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-color-1 {
    background: #fef3c7;
    color: #b45309;
}

.badge-color-2 {
    background: #dcfce7;
    color: #15803d;
}

.badge-color-3 {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-color-4 {
    background: #f1f5f9;
    color: #64748b;
}

.badge-color-5 {
    background: #fce7f3;
    color: #be185d;
}

.badge-color-received {
    background: #dcfce7;
    color: #15803d;
}

.badge-color-submitted {
    background: #fef3c7;
    color: #b45309;
}

.badge-color-already-having {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-color-rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-color-not-valid {
    background: #f1f5f9;
    color: #64748b;
}


/* ==========================================
   MATCH HIGHLIGHT
========================================== */

.truck-card.match-exact {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16), var(--shadow-sm);
}

.truck-card.match-exact::before {
    background: linear-gradient(180deg, #fbbf24, #f59e0b);
    opacity: 1;
}


/* ==========================================
   RESPONSIVE
========================================== */

@media (min-width: 560px) {
    .toolbar {
        flex-direction: row;
    }
    .search-box {
        flex: 1;
    }
    .download-btn {
        width: auto;
        padding: 13px 22px;
    }
}

@media (min-width: 600px) {
    .truck-card-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}


/* ==========================================
   DRILL-DOWN MODAL
========================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 33, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal-sheet {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -20px 50px -10px rgba(18, 23, 43, 0.35);
    animation: sheet-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheet-in {
    from {
        transform: translateY(24px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(67, 56, 202, 0.06), rgba(37, 99, 235, 0.04));
}

.modal-header h2 {
    margin: 0;
    font-family: "Sora", "Inter", sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
}

.modal-close {
    border: none;
    background: var(--surface);
    color: var(--muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    background: #fee2e2;
    color: var(--danger);
}

.modal-body {
    padding: 8px 20px 20px;
    overflow-y: auto;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--faint);
    text-transform: uppercase;
    flex: 0 0 42%;
    padding-top: 1px;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    text-align: right;
    flex: 1;
}

@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }
    .modal-sheet {
        border-radius: 22px;
        max-width: 480px;
    }
}


/* ==========================================
   SKELETON LOADING STATE
========================================== */

.skeleton-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 17px 17px 17px 20px;
    box-shadow: var(--shadow-sm);
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--line) 25%, rgba(148, 163, 184, 0.25) 37%, var(--line) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

.skeleton-line.w-40 { width: 40%; height: 18px; margin-bottom: 10px; }
.skeleton-line.w-25 { width: 25%; margin-bottom: 16px; }
.skeleton-line.w-70 { width: 70%; margin-bottom: 6px; }
.skeleton-line.w-50 { width: 50%; }

.skeleton-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding-top: 13px;
    border-top: 1px dashed var(--line);
}

@keyframes skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}


/* ==========================================
   SCROLL TO TOP
========================================== */

.scroll-top-btn {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 50;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 24px -6px rgba(67, 56, 202, 0.55);
    opacity: 0;
    transform: translateY(12px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-top-btn:active {
    transform: scale(0.92);
}
