/* Portal wide additions to the theme: the colours the design sets differently,
   and the few rules Bootstrap has no utility for. Pages use utilities for the
   rest. */

/* Colours ---------------------------------------------------------------- */

[data-bs-theme=light] {
    --bs-app-bg: #f3f4f6;
    --bs-body-color: #1f2328;
    --bs-body-color-rgb: 31, 35, 40;
    --bs-secondary-color: #5f6670;
    --bs-border-color: #e4e6ea;

    --bs-warning: #e0a100;
    --bs-warning-rgb: 224, 161, 0;
    --bs-warning-bg-subtle: #fff3d6;
    --bs-warning-text-emphasis: #7a5000;
    --bs-warning-border-subtle: #f3d68a;
}

/* Alerts: the design's palette, set on the alert classes only so the status
   pills (which share the subtle colours) keep theirs. `--notice-icon` colours
   the round icon of an x-notice. */
[data-bs-theme=light] .alert-danger {
    --bs-alert-bg: #fdf0f1;
    --bs-alert-border-color: #f3c7cd;
    --bs-alert-color: #6e0b18;
    --bs-alert-link-color: #4a0610;
    --notice-icon: #c8102e;
}

[data-bs-theme=light] .alert-warning {
    --bs-alert-bg: #fff8e6;
    --bs-alert-border-color: #f2da9b;
    --bs-alert-color: #5c3d00;
    --bs-alert-link-color: #3d2800;
    --notice-icon: #b7791f;
}

[data-bs-theme=light] .alert-info {
    --bs-alert-bg: #eef5fb;
    --bs-alert-border-color: #c5dcef;
    --bs-alert-color: #0b3a5c;
    --bs-alert-link-color: #072740;
    --notice-icon: #1f6fb2;
}

[data-bs-theme=light] .alert-success {
    --bs-alert-bg: #eff8f2;
    --bs-alert-border-color: #c6e7d1;
    --bs-alert-color: #1d4d2c;
    --bs-alert-link-color: #133a20;
    --notice-icon: #2e9a52;
}

/* The theme also sets these colours outright on each alert class, so the
   palette above is applied to the properties as well as the variables. */
[data-bs-theme=light] .alert-danger,
[data-bs-theme=light] .alert-warning,
[data-bs-theme=light] .alert-info,
[data-bs-theme=light] .alert-success {
    background-color: var(--bs-alert-bg);
    border-color: var(--bs-alert-border-color);
    color: var(--bs-alert-color);
}

[data-bs-theme=light] .alert-danger .alert-link,
[data-bs-theme=light] .alert-warning .alert-link,
[data-bs-theme=light] .alert-info .alert-link,
[data-bs-theme=light] .alert-success .alert-link {
    color: var(--bs-alert-link-color);
}

.alert {
    --bs-alert-border-radius: .5rem;
}

.notice {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr);
    gap: .875rem;
    padding: 1rem 1.25rem;
    line-height: 1.55;
}

.notice-icon {
    width: 1.375rem;
    height: 1.375rem;
    margin-top: .1rem;
    background-color: var(--notice-icon, var(--bs-secondary-color));
    color: #fff;
}

.notice-icon svg {
    width: .875rem;
    height: .875rem;
    stroke-width: 3;
}

.notice-glyph {
    font-family: Georgia, serif;
    font-size: .8125rem;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
}

/* Thai on the left, English on the right, stacked when narrow. */
.notice-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
    gap: .75rem 2rem;
}

.notice-english {
    border-left: 1px solid var(--bs-alert-border-color);
    padding-left: 1.25rem;
}

/* Top bar ---------------------------------------------------------------- */

/* The bar sits in the flow (sticky), so the page no longer makes room for the
   theme's fixed menu. */
.page-wrapper {
    margin-top: 0;
    padding-top: 0;
    /* The theme hides the overflow, which stops sticky-bottom action bars
       from sticking. Clip cuts the same overflow without that side effect. */
    overflow: clip;
}

.app-topbar {
    --bs-navbar-padding-y: 0;
    min-height: 4rem;
}

.app-topbar-brand img {
    height: 2.25rem;
}

.app-topbar .navbar-nav .nav-link {
    color: var(--bs-body-color);
}

.app-topbar .navbar-nav .nav-link.active {
    color: var(--bs-primary);
    font-weight: 600;
}

/* Dark mode toggle: a track with a round knob that carries a sun (light)
   or a moon (dark) and slides across in dark mode. */
.theme-toggle {
    position: relative;
    width: 2.375rem;
    height: 1.375rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background-color: var(--bs-border-color);
}

.theme-toggle-knob {
    position: absolute;
    top: .125rem;
    left: .125rem;
    width: 1.125rem;
    height: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .15);
    transition: transform .15s ease;
}

.theme-toggle-knob svg {
    width: .75rem;
    height: .75rem;
    stroke-width: 2.4;
}

.theme-icon-light {
    color: #d97706;
    fill: #f59e0b;
}

.theme-icon-dark {
    color: #334155;
    fill: #334155;
}

[data-bs-theme=light] .theme-icon-dark,
[data-bs-theme=dark] .theme-icon-light {
    display: none;
}

[data-bs-theme=dark] .theme-toggle {
    background-color: #334155;
}

[data-bs-theme=dark] .theme-toggle-knob {
    transform: translateX(1rem);
}

.app-topbar .avatar {
    width: 2rem;
    height: 2rem;
    font-size: .75rem;
}

@media (min-width: 992px) {
    .app-topbar .navbar-nav .nav-link {
        display: flex;
        align-items: center;
        height: 4rem;
        padding-left: 0;
        padding-right: 0;
    }

    .app-topbar .navbar-nav .nav-link.active {
        box-shadow: inset 0 -2px 0 var(--bs-primary);
    }
}

/* Status pill ------------------------------------------------------------ */

.status-dot {
    width: .375rem;
    height: .375rem;
}

/* Tables ----------------------------------------------------------------- */

.table-list thead th {
    text-transform: none;
}

.table-list tbody tr[data-href] {
    cursor: pointer;
}

/* Detail pages ----------------------------------------------------------- */

/* Headline figures under a page title, split by thin rules. */
.header-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    row-gap: .75rem;
}

.header-stat {
    padding-right: 1.25rem;
}

@media (min-width: 768px) {
    .header-stat + .header-stat {
        border-left: 1px solid var(--bs-border-color);
        padding-left: 1.25rem;
    }
}

.section-card-header {
    min-height: 3rem;
}

/* The title stays beside its icon and shrinks first; on a narrow card the
   bar's right end (aside) drops to its own line instead. */
.section-card-title {
    flex: 1 1 12rem;
    min-width: 0;
}

.section-card-icon {
    width: 1.625rem;
    height: 1.625rem;
    background-color: var(--bs-border-color);
    color: var(--bs-secondary-color);
}

.section-card-icon svg {
    width: .95rem;
    height: .95rem;
}

/* Label and value pairs in two columns, one rule between rows. */
.detail-list {
    display: grid;
    grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr);
    column-gap: 1rem;
    margin: 0;
}

.detail-list dt,
.detail-list dd {
    margin: 0;
    padding: .55rem 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.detail-list dt {
    font-weight: 400;
    color: var(--bs-secondary-color);
}

.detail-list dd {
    font-weight: 500;
}

.detail-list dt:nth-last-of-type(1),
.detail-list dd:nth-last-of-type(1) {
    border-bottom: 0;
}

/* In a narrow side card the values sit on the right. */
.detail-list-end dd {
    text-align: right;
}

/* The columns a GR request adds up, tinted in the brand colour. Bootstrap
   paints table cells from --bs-table-bg, which outranks a plain background. */
.table .col-this-gr {
    --bs-table-bg: rgba(var(--bs-primary-rgb), .08);
}

.table thead .col-this-gr {
    --bs-table-bg: rgba(var(--bs-primary-rgb), .12);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600 !important;
}

/* The request log as a timeline: a dot per event, a rule down to the next. */
.timeline-item {
    display: grid;
    grid-template-columns: .625rem minmax(0, 1fr);
    gap: .75rem;
}

.timeline-dot {
    width: .5rem;
    height: .5rem;
    margin-top: .45rem;
    background-color: var(--bs-tertiary-color);
}

/* Newest first, so the latest event leads in green. */
.timeline-item:first-child .timeline-dot {
    background-color: var(--bs-success);
}

/* A collapse toggle that reads Show or Hide from Bootstrap's aria-expanded. */
[aria-expanded="false"] .when-open,
[aria-expanded="true"] .when-closed {
    display: none;
}

.timeline-rule {
    width: 1px;
    background-color: var(--bs-border-color);
}

.timeline-item:last-child .timeline-rule {
    background-color: transparent;
}

@media (min-width: 1200px) {
    .detail-aside {
        position: sticky;
        top: 5rem;
    }
}

/* Lets a flex or grid child shrink below its content, so long text wraps
   instead of pushing into its neighbour. Bootstrap 5 has no such utility. */
.min-w-0 {
    min-width: 0;
}

/* Home: queue cards and work cards --------------------------------------- */

.queue-card {
    border: 1.5px solid var(--bs-border-color);
    cursor: pointer;
}

.queue-card.active {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), .08);
}

.queue-card.active .queue-card-label,
.queue-card.active .queue-card-count {
    color: var(--bs-primary);
}

.queue-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
}

.queue-card.active .queue-card-icon {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary);
}

/* A drop shadow so neighbouring cards read as separate boxes. */
.work-card {
    box-shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    transition: border-color .15s, box-shadow .15s;
}

.work-card:hover {
    border-color: var(--bs-primary-border-subtle);
    box-shadow: 0 4px 12px rgba(16, 24, 40, .12);
}

/* Login: one centred card (welcome, staff and vendor sign in) -------------- */

.login-page {
    min-height: 100vh;
    padding: 48px 16px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

.login-card-wide {
    max-width: 560px;
}

.login-card .card-footer {
    border-radius: 0 0 10px 10px;
}

.login-kicker {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.login-kicker-vendor {
    color: #0e6560;
}

.btn-vendor {
    --bs-btn-color: #0e6560;
    --bs-btn-bg: transparent;
    --bs-btn-border-color: #2ba59d;
    --bs-btn-border-width: 1.5px;
    --bs-btn-hover-color: #0e6560;
    --bs-btn-hover-bg: #e6f4f3;
    --bs-btn-hover-border-color: #2ba59d;
    --bs-btn-active-color: #0e6560;
    --bs-btn-active-bg: #d2ebe9;
    --bs-btn-active-border-color: #2ba59d;
}

[data-bs-theme=dark] .login-kicker-vendor,
[data-bs-theme=dark] .btn-vendor {
    --bs-btn-color: #5fc9c1;
    --bs-btn-hover-color: #5fc9c1;
    --bs-btn-hover-bg: rgba(43, 165, 157, .15);
    --bs-btn-active-color: #5fc9c1;
    --bs-btn-active-bg: rgba(43, 165, 157, .25);
    color: #5fc9c1;
}
