/* =========================================================================
   Thông tin giờ tàu giá vé – Design system "Modern Railway"
   Bootstrap 5 lo lưới và tiện ích; file này đặt màu, chữ và các thành phần riêng.
   ========================================================================= */

:root {
    --rail-navy: #153B60;
    --rail-navy-600: #0F2E4C;
    --rail-navy-050: #EAF0F6;
    --rail-gold: #F2C500;
    --rail-gold-050: #FFF7D1;
    --rail-gold-ink: #6B5300;
    --rail-bg: #FFFFFF;
    --rail-bg-soft: #F5F7FA;
    --rail-text: #253041;
    --rail-muted: #64748B;
    --rail-border: #E2E8F0;
    --rail-radius: 12px;
    --rail-radius-sm: 8px;
    --rail-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
    --rail-shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
    --rail-header-h: 60px;

    /* Theme Bootstrap */
    --bs-body-font-family: "Be Vietnam Pro", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--rail-text);
    --bs-body-bg: var(--rail-bg-soft);
    --bs-emphasis-color: var(--rail-text);
    --bs-secondary-color: var(--rail-muted);
    --bs-border-color: var(--rail-border);
    --bs-border-radius: var(--rail-radius-sm);
    --bs-border-radius-lg: var(--rail-radius);
    --bs-primary: var(--rail-navy);
    --bs-primary-rgb: 21, 59, 96;
    --bs-link-color: var(--rail-navy);
    --bs-link-color-rgb: 21, 59, 96;
    --bs-link-hover-color: var(--rail-navy-600);
    --bs-link-hover-color-rgb: 15, 46, 76;
    --bs-focus-ring-color: rgba(21, 59, 96, .2);
}

@media (min-width: 992px) {
    :root { --rail-header-h: 68px; }
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-size: .9375rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6 { color: var(--rail-navy); font-weight: 700; letter-spacing: -.01em; }
h1:focus { outline: none; }
a { text-underline-offset: .2em; }

/* ---------- Nút & form ---------- */
.btn { --bs-btn-font-weight: 600; --bs-btn-border-radius: var(--rail-radius-sm); min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: 34px; }
.btn-primary {
    --bs-btn-bg: var(--rail-navy); --bs-btn-border-color: var(--rail-navy);
    --bs-btn-hover-bg: var(--rail-navy-600); --bs-btn-hover-border-color: var(--rail-navy-600);
    --bs-btn-active-bg: var(--rail-navy-600); --bs-btn-active-border-color: var(--rail-navy-600);
    --bs-btn-disabled-bg: var(--rail-navy); --bs-btn-disabled-border-color: var(--rail-navy);
    --bs-btn-focus-shadow-rgb: 21, 59, 96;
}
.btn-outline-primary {
    --bs-btn-color: var(--rail-navy); --bs-btn-border-color: var(--rail-border);
    --bs-btn-hover-bg: var(--rail-navy-050); --bs-btn-hover-color: var(--rail-navy); --bs-btn-hover-border-color: #C9D6E3;
    --bs-btn-active-bg: var(--rail-navy-050); --bs-btn-active-color: var(--rail-navy); --bs-btn-active-border-color: #C9D6E3;
    --bs-btn-bg: #fff;
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--rail-border); --bs-btn-hover-bg: var(--rail-bg-soft); --bs-btn-hover-border-color: var(--rail-border); }
.form-label { font-size: .8125rem; font-weight: 600; color: var(--rail-muted); margin-bottom: .35rem; }
.form-control, .form-select { min-height: 44px; border-color: var(--rail-border); border-radius: var(--rail-radius-sm); color: var(--rail-text); }
.form-control:focus, .form-select:focus { border-color: var(--rail-navy); box-shadow: 0 0 0 .2rem rgba(21, 59, 96, .15); }
.form-select { background-position: right .85rem center; }
.alert { border-radius: var(--rail-radius-sm); }
.validation-message { color: var(--bs-danger); font-size: .8125rem; margin-top: .25rem; }

/* ---------- Khung trang ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-main { flex: 1 0 auto; padding: 1rem 0 2rem; }
.app-container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 768px) { .app-container { padding: 0 1.5rem; } .app-main { padding: 1.5rem 0 3rem; } }

/* ---------- Header ---------- */
.app-header {
    position: sticky; top: 0; z-index: 1030;
    background: #fff;
    border-bottom: 1px solid var(--rail-border);
    box-shadow: inset 0 -3px 0 var(--rail-gold);
}
.app-header .app-container { height: var(--rail-header-h); display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; min-width: 0; }
.brand img { height: 36px; width: auto; flex-shrink: 0; }
.brand-name {
    color: var(--rail-navy); font-weight: 700; font-size: .8125rem; line-height: 1.2;
    letter-spacing: .02em; text-transform: uppercase; max-width: 9.5rem;
    padding-left: .75rem; border-left: 1px solid var(--rail-border);
}
@media (min-width: 400px) { .brand-name { max-width: none; font-size: .875rem; } }
@media (min-width: 992px) { .brand img { height: 44px; } .brand-name { font-size: 1rem; } }

.app-nav { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.app-nav .nav-link, .app-nav .dropdown-toggle {
    color: var(--rail-text); font-weight: 500; padding: .5rem .8rem; border-radius: var(--rail-radius-sm);
    display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; text-decoration: none;
    background: none; border: 0;
}
.app-nav .nav-link:hover, .app-nav .dropdown-toggle:hover { background: var(--rail-bg-soft); color: var(--rail-navy); }
.app-nav .nav-link.active { color: var(--rail-navy); font-weight: 600; background: var(--rail-navy-050); }
.app-nav .btn-login { margin-left: .5rem; }
.dropdown-menu { --bs-dropdown-border-color: var(--rail-border); --bs-dropdown-border-radius: var(--rail-radius); --bs-dropdown-link-active-bg: var(--rail-navy-050); --bs-dropdown-link-active-color: var(--rail-navy); box-shadow: var(--rail-shadow-lg); padding: .5rem; }
.dropdown-item { border-radius: 6px; padding: .5rem .75rem; }
.dropdown-header { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rail-muted); }

.menu-toggle {
    margin-left: auto; width: 44px; height: 44px; border-radius: var(--rail-radius-sm);
    border: 1px solid var(--rail-border); background: #fff; color: var(--rail-navy);
    display: inline-flex; align-items: center; justify-content: center;
}

/* Menu điện thoại (offcanvas điều khiển bằng Blazor) */
.mobile-menu { --bs-offcanvas-width: min(320px, 86vw); }
.mobile-menu .offcanvas-header { border-bottom: 1px solid var(--rail-border); min-height: var(--rail-header-h); }
.mobile-menu-group { padding: .75rem 0; border-bottom: 1px solid var(--rail-border); }
.mobile-menu-group:last-child { border-bottom: 0; }
.mobile-menu-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rail-muted); font-weight: 600; padding: 0 .25rem .35rem; }
.mobile-menu a, .mobile-menu button.menu-link {
    display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 48px; padding: .5rem .75rem;
    border-radius: var(--rail-radius-sm); color: var(--rail-text); text-decoration: none; font-weight: 500;
    background: none; border: 0; text-align: left;
}
.mobile-menu a:hover, .mobile-menu button.menu-link:hover { background: var(--rail-bg-soft); }
.mobile-menu a.active { background: var(--rail-navy-050); color: var(--rail-navy); font-weight: 600; }

/* ---------- Footer ---------- */
.app-footer {
    background: var(--rail-navy); color: rgba(255, 255, 255, .78); font-size: .8125rem; line-height: 1.6;
    border-top: 3px solid var(--rail-gold);
}
.app-footer .app-container { padding-top: 1.5rem; padding-bottom: 1rem; }
.footer-main { display: grid; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.footer-org { color: var(--rail-gold); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.footer-site { color: #fff; font-size: 1rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; margin-top: .15rem; }
.footer-desc { margin: .35rem 0 0; max-width: 34rem; }
.footer-note {
    display: flex; gap: .5rem; align-items: flex-start; margin: 0; padding: .625rem .75rem;
    background: rgba(255, 255, 255, .06); border-left: 3px solid var(--rail-gold); border-radius: 0 var(--rail-radius-sm) var(--rail-radius-sm) 0;
}
.footer-note svg { color: var(--rail-gold); margin-top: .15rem; }
.footer-note strong { color: #fff; font-weight: 600; }
.footer-bottom { display: flex; flex-direction: column; gap: .15rem; padding-top: .875rem; color: rgba(255, 255, 255, .6); font-size: .75rem; }
@media (min-width: 768px) {
    .app-footer .app-container { padding-top: 1.75rem; padding-bottom: 1.125rem; }
    .footer-main { grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); align-items: center; gap: 2rem; }
    .footer-bottom { flex-direction: row; justify-content: space-between; }
}

/* ---------- Bề mặt, tiêu đề trang ---------- */
.surface { background: #fff; border: 1px solid var(--rail-border); border-radius: var(--rail-radius); box-shadow: var(--rail-shadow); }
.surface-body { padding: 1rem; }
@media (min-width: 768px) { .surface-body { padding: 1.25rem 1.5rem; } }
.surface-header { padding: .875rem 1rem; border-bottom: 1px solid var(--rail-border); display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
@media (min-width: 768px) { .surface-header { padding: 1rem 1.5rem; } }
.surface-title { font-size: 1rem; font-weight: 700; color: var(--rail-navy); margin: 0; }

.page-head { margin-bottom: 1rem; }
.page-title { font-size: 1.25rem; margin: 0; }
.page-sub { color: var(--rail-muted); font-size: .875rem; margin: .25rem 0 0; }
@media (min-width: 768px) { .page-title { font-size: 1.5rem; } }

.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--rail-muted); }

/* ---------- Thanh tra cứu: tab Giờ tàu / Giá vé + chọn tuyến ---------- */
.tracuu-bar { display: flex; flex-direction: column; gap: .625rem; margin-bottom: 1rem; }
.route-row { display: flex; gap: .5rem; align-items: flex-end; }
.route-field { flex: 1 1 auto; min-width: 0; }
.route-field .form-select { font-weight: 600; color: var(--rail-navy); background-color: #fff; box-shadow: var(--rail-shadow); }
.btn-legend { flex-shrink: 0; min-width: 44px; padding-left: .7rem; padding-right: .7rem; background: #fff; }
@media (min-width: 768px) {
    .tracuu-bar { flex-direction: row; align-items: flex-end; gap: 1rem; }
    .route-row { flex: 1 1 auto; gap: .75rem; }
    .route-field { flex: 0 1 420px; }
}

.seg {
    display: inline-flex; padding: 4px; gap: 4px; background: #fff; border: 1px solid var(--rail-border);
    border-radius: 10px; box-shadow: var(--rail-shadow); width: 100%;
}
@media (min-width: 768px) { .seg { width: auto; } }
.seg > a, .seg > button, .seg > label {
    flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; padding: .4rem 1rem; border-radius: 7px; border: 0; background: none;
    font-weight: 600; font-size: .875rem; color: var(--rail-muted); text-decoration: none; white-space: nowrap;
    letter-spacing: .02em; cursor: pointer; transition: background-color .15s, color .15s;
}
.seg > a:hover, .seg > button:hover, .seg > label:hover { color: var(--rail-navy); background: var(--rail-bg-soft); }
.seg > .active, .seg > input:checked + label {
    background: var(--rail-navy); color: #fff; box-shadow: 0 1px 2px rgba(21, 59, 96, .3);
}
.seg > .active:hover, .seg > input:checked + label:hover { background: var(--rail-navy); color: #fff; }
.seg-upper > a, .seg-upper > button { text-transform: uppercase; }
.seg > input { position: absolute; opacity: 0; pointer-events: none; }
.seg-sm > a, .seg-sm > button, .seg-sm > label { min-height: 36px; font-size: .8125rem; padding: .3rem .75rem; }

.btn-legend { white-space: nowrap; }

/* ---------- Bảng dữ liệu ---------- */
.data-wrap {
    position: relative; overflow: auto; max-height: 72vh; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    border-top: 1px solid var(--rail-border);
}
.data-wrap.no-max { max-height: none; }
.surface > .data-wrap:last-child { border-radius: 0 0 var(--rail-radius) var(--rail-radius); }

.data-table {
    width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem;
    font-variant-numeric: tabular-nums; color: var(--rail-text); margin: 0;
}
.data-table th, .data-table td { padding: .55rem .75rem; border-bottom: 1px solid #EEF2F6; vertical-align: middle; background: #fff; }
.data-table thead th {
    position: sticky; top: 0; z-index: 2; background: var(--rail-navy-050); color: var(--rail-navy);
    font-weight: 600; font-size: .8125rem; white-space: nowrap; border-bottom: 1px solid #D3DEEA;
}
.data-table tbody tr:nth-child(even) td { background: #FAFBFD; }
.data-table tfoot td { background: var(--rail-bg-soft); font-weight: 600; }
@media (hover: hover) {
    .data-table tbody tr:hover td { background: var(--rail-gold-050); }
}
/* Cột đầu (tên ga / mã) cố định khi cuộn ngang */
.data-table .col-sticky { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--rail-border); }
.data-table thead .col-sticky { z-index: 3; }
.data-table .col-ga { min-width: 8.5rem; font-weight: 500; white-space: nowrap; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .center { text-align: center; white-space: nowrap; }
.data-table .muted { color: var(--rail-muted); }
.data-table .price { text-align: right; white-space: nowrap; font-weight: 600; color: var(--rail-navy); }
.data-table .code { font-weight: 600; white-space: nowrap; color: var(--rail-navy); }
@media (min-width: 992px) { .data-table { font-size: .9375rem; } .data-table th, .data-table td { padding: .6rem 1rem; } }

.time { font-weight: 600; color: var(--rail-text); }
.no-time { color: #B4BFCC; }
.next-day {
    display: inline-block; margin-left: .3rem; padding: 0 .4rem; border-radius: 999px;
    background: var(--rail-gold-050); color: var(--rail-gold-ink); font-size: .6875rem; font-weight: 700; line-height: 1.5;
    vertical-align: 1px;
}
.table-note { font-size: .8125rem; color: var(--rail-muted); padding: .75rem 1rem; display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
@media (min-width: 768px) { .table-note { padding: .75rem 1.5rem; } }

/* Tóm tắt kết quả */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: 999px;
    background: var(--rail-bg-soft); border: 1px solid var(--rail-border); font-size: .8125rem; font-weight: 500; color: var(--rail-text);
}
.chip-train { background: var(--rail-navy); border-color: var(--rail-navy); color: #fff; font-weight: 700; }

/* ---------- Trạng thái ---------- */
.state { padding: 2.5rem 1rem; text-align: center; color: var(--rail-muted); }
.state .bi { font-size: 1.75rem; color: #B4BFCC; display: block; margin-bottom: .5rem; }
.spinner-border { --bs-spinner-border-width: .18em; }

/* ---------- Form tra cứu ---------- */
.search-card .btn-search { width: 100%; }
@media (min-width: 768px) { .search-card .btn-search { width: auto; min-width: 9rem; } }

/* ---------- Modal / bottom sheet (Blazor điều khiển, không cần JS Bootstrap) ---------- */
.modal.d-block { background: transparent; }
.modal-content { border: 0; border-radius: var(--rail-radius); box-shadow: var(--rail-shadow-lg); }
.modal-header { border-bottom-color: var(--rail-border); }
.modal-title { color: var(--rail-navy); font-weight: 700; font-size: 1.0625rem; }
.modal-backdrop.show { opacity: .4; }
@media (max-width: 575.98px) {
    .modal-sheet .modal-dialog { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; max-width: none; height: auto; min-height: 0; }
    .modal-sheet .modal-content { border-radius: 16px 16px 0 0; max-height: 85vh; animation: sheet-up .22s ease-out; }
    .modal-sheet .modal-header::before {
        content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px;
        border-radius: 4px; background: var(--rail-border);
    }
    .modal-sheet .modal-header { position: relative; padding-top: 1.1rem; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- Danh sách sắp xếp (Admin) ---------- */
.sort-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.sort-item {
    display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem .75rem; min-height: 52px;
    background: #fff; border: 1px solid var(--rail-border); border-radius: var(--rail-radius-sm);
}
.sort-index { width: 1.75rem; height: 1.75rem; border-radius: 999px; background: var(--rail-navy-050); color: var(--rail-navy); font-weight: 700; font-size: .8125rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sort-name { font-weight: 700; color: var(--rail-navy); margin-right: auto; }
.icon-btn {
    width: 40px; height: 40px; border-radius: var(--rail-radius-sm); border: 1px solid var(--rail-border); background: #fff;
    color: var(--rail-text); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover:not(:disabled) { background: var(--rail-bg-soft); color: var(--rail-navy); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.danger:hover:not(:disabled) { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }

/* Thanh điều hướng Admin cuộn ngang trên điện thoại */
.scroll-x { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { display: none; }
.admin-nav { display: inline-flex; gap: .25rem; padding: 4px; background: #fff; border: 1px solid var(--rail-border); border-radius: 10px; box-shadow: var(--rail-shadow); }
.admin-nav a { white-space: nowrap; padding: .5rem .9rem; border-radius: 7px; color: var(--rail-muted); font-weight: 600; font-size: .875rem; text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; gap: .4rem; }
.admin-nav a:hover { background: var(--rail-bg-soft); color: var(--rail-navy); }
.admin-nav a.active { background: var(--rail-navy); color: #fff; }

/* ---------- Đăng nhập ---------- */
.auth-card { max-width: 420px; margin: 1rem auto; }
.auth-card .auth-logo { height: 56px; width: auto; display: block; margin: 0 auto .75rem; }

/* ---------- Blazor: thông báo lỗi, vòng tải trang ---------- */
#blazor-error-ui { display: none; position: fixed; inset: auto 0 0 0; z-index: 2000; }
.loading-progress { position: absolute; display: block; width: 6rem; height: 6rem; inset: 30vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: var(--rail-border); stroke-width: .5rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--rail-gold);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: 600; color: var(--rail-navy); inset: calc(30vh + 2.5rem) 0 auto 0; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Đang tải"); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.surface:focus { outline: none; }
.surface[tabindex="-1"] { scroll-margin-top: calc(var(--rail-header-h) + 12px); }
