/*
 * Shared look on top of Tabler for every page: a Thai font, and sizes that keep Thai vowels and tone
 * marks readable. Tabler's defaults are tuned for Latin text, which reads fine much smaller.
 */
:root {
    --tblr-font-sans-serif: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --tblr-body-font-family: var(--tblr-font-sans-serif);
    --tblr-body-font-size: 0.9375rem;
    --tblr-body-line-height: 1.6;
    --tblr-font-size-h1: 1.75rem;
    --tblr-font-size-h2: 1.375rem;
    --tblr-font-size-h3: 1.125rem;
    --tblr-font-size-h4: 1.0625rem;
    --tblr-font-size-h5: 1rem;
    --tblr-font-size-h6: 0.9375rem;
    --tblr-line-height-h1: 1.4;
    --tblr-line-height-h2: 1.45;
    --tblr-line-height-h3: 1.5;
    --tblr-line-height-h4: 1.5;
    --tblr-line-height-h5: 1.5;
    --tblr-line-height-h6: 1.5;
    --brand-gradient: linear-gradient(135deg, #0b3a75 0%, #066fd1 55%, #6250d6 100%);
}

/* Thai has no capitals, and letter spacing pulls tone marks away from their consonants. */
.table thead th,
.page-pretitle,
.subheader,
.dropdown-header,
.nav-section {
    text-transform: none;
    letter-spacing: normal;
}

.table thead th {
    font-size: 0.8125rem;
    line-height: 1.4;
}

.page-pretitle,
.subheader {
    font-size: 0.8125rem;
}

.badge {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
}

.form-text,
.small,
small {
    line-height: 1.55;
}

.tabular {
    font-variant-numeric: tabular-nums;
}

/* The system's mark: a shop icon on the brand gradient. */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: var(--brand-gradient);
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 0.25rem 0.75rem rgba(6, 111, 209, 0.3);
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
}

.brand-tagline {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
}

/*
 * Tabler's soft "-lt" fills keep the full-strength colour for text, which is too faint on its tint
 * for small Thai text (yellow is about 2:1). Darker steps of the same hues read at 4.5:1 or better.
 */
.bg-green-lt { color: #1b7a30 !important; }
.bg-yellow-lt { color: #8a5300 !important; }
.bg-red-lt { color: #b42525 !important; }
.bg-azure-lt { color: #1f6aa8 !important; }
.bg-orange-lt { color: #b04a06 !important; }
.bg-purple-lt { color: #8a2fa3 !important; }
.bg-pink-lt { color: #b32561 !important; }
.bg-teal-lt { color: #0b7a5a !important; }
.bg-indigo-lt { color: #3d4fbf !important; }

/* Nothing-here-yet boxes: a smaller icon than Tabler's, so a short list doesn't look broken. */
.empty-icon {
    font-size: 2.25rem;
    line-height: 1;
    color: var(--tblr-secondary);
    margin-bottom: 0.75rem;
}

.empty-title {
    font-size: 1rem;
    font-weight: 600;
}

.empty-subtitle {
    max-width: 28rem;
    margin-inline: auto;
}

/* Payslip totals (owner's and employee's pages): label left, amount right, net figure last and largest. */
.payslip-summary {
    max-width: 26rem;
    margin: 1rem 0 0 auto;
    padding: 0.75rem 1rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius-lg, 0.5rem);
    background: var(--tblr-bg-surface-secondary, #f6f8fb);
}

.payslip-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
}

.payslip-summary dt {
    font-weight: 400;
}

.payslip-summary dd {
    margin: 0;
    text-align: end;
    white-space: nowrap;
}

.payslip-summary-subtotal {
    font-weight: 600;
    border-top: 1px dashed var(--tblr-border-color);
    margin-top: 0.25rem;
    padding-top: 0.4rem !important;
}

.payslip-summary-net {
    font-size: 1.25rem;
    font-weight: 700;
    border-top: 1px solid var(--tblr-border-color);
    margin-top: 0.25rem;
    padding-top: 0.5rem !important;
}

.payslip-summary-net dt {
    font-weight: 700;
}

/*
 * AI assistant: a round button in the bottom-right corner of every page, opening a chat panel above it.
 * On a phone the panel fills the screen, and the button sits above the employee tab bar.
 */
.assistant-fab {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1045;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 0.5rem 1.5rem rgba(6, 111, 209, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.assistant-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.75rem rgba(6, 111, 209, 0.5);
}

.assistant-fab:focus-visible {
    outline: 3px solid rgba(6, 111, 209, 0.45);
    outline-offset: 3px;
}

.assistant-fab-close,
.assistant-fab[aria-expanded="true"] .assistant-fab-open {
    display: none;
}

.assistant-fab[aria-expanded="true"] .assistant-fab-close {
    display: inline;
}

/* How many things look wrong, until the panel has been opened. */
.assistant-fab-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.3rem;
    border: 2px solid var(--tblr-bg-surface);
    border-radius: 999px;
    background: var(--tblr-danger);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.125rem;
    text-align: center;
}

.assistant-panel {
    position: fixed;
    right: 1.5rem;
    bottom: 5.75rem;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    width: 24rem;
    height: min(38rem, calc(100vh - 8rem));
    height: min(38rem, calc(100dvh - 8rem));
    overflow: hidden;
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(24, 36, 51, 0.22);
    transform-origin: bottom right;
    animation: assistant-pop 0.18s ease-out;
}

.assistant-panel[hidden],
.assistant-suggestions[hidden],
.assistant-alerts[hidden],
.assistant-fab-badge[hidden] {
    display: none;
}

@keyframes assistant-pop {
    from {
        opacity: 0;
        transform: translateY(0.5rem) scale(0.97);
    }
}

.assistant-panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
    background: var(--brand-gradient);
    color: #fff;
}

.assistant-panel-header .assistant-avatar {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.assistant-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.assistant-panel-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

.assistant-panel-button,
.assistant-panel-button:focus {
    border: 0;
    background: transparent;
    color: #fff;
}

.assistant-panel-button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.assistant-panel-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.assistant-chat {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
    padding: 1rem;
    overflow-y: auto;
    background: var(--tblr-bg-surface-secondary);
}

.assistant-bubble {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 1rem;
    line-height: 1.55;
    white-space: pre-line;
}

.assistant-bubble-ai {
    align-self: flex-start;
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-bottom-left-radius: 0.25rem;
}

.assistant-bubble-me {
    align-self: flex-end;
    background: var(--tblr-primary);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.assistant-thinking {
    color: var(--tblr-secondary);
}

.assistant-suggestions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
    margin-top: 0.25rem;
}

.assistant-suggestions-label {
    font-size: 0.75rem;
    color: var(--tblr-secondary);
}

.assistant-chip {
    border: 1px solid rgba(6, 111, 209, 0.35);
    border-radius: 999px;
    background: var(--tblr-bg-surface);
    color: var(--tblr-primary);
    text-align: start;
    white-space: normal;
}

.assistant-chip:hover {
    background: rgba(6, 111, 209, 0.08);
    color: var(--tblr-primary);
}

.assistant-privacy {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--tblr-secondary);
}

.assistant-alerts {
    padding: 0.625rem 0.75rem;
    border: 1px solid rgba(245, 159, 0, 0.35);
    border-radius: 0.75rem;
    background: rgba(245, 159, 0, 0.08);
}

.assistant-alerts-title {
    margin: 0 0 0.375rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #8a5300;
}

.assistant-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.assistant-alert {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.assistant-alert + .assistant-alert {
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(245, 159, 0, 0.35);
}

.assistant-alert-icon {
    color: #8a5300;
}

.assistant-alert-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    min-width: 0;
}

.assistant-alert-button {
    border: 1px solid rgba(138, 83, 0, 0.35);
    border-radius: 999px;
    background: var(--tblr-bg-surface);
    color: #8a5300;
}

.assistant-alert-button:hover {
    background: rgba(245, 159, 0, 0.15);
    color: #8a5300;
}

/* A form the assistant filled in: its note on top, and each filled field marked until it is changed. */
.assistant-fill-note {
    margin-bottom: 1rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid rgba(6, 111, 209, 0.3);
    border-radius: 0.5rem;
    background: rgba(6, 111, 209, 0.07);
    font-size: 0.875rem;
}

.assistant-fill-note-title {
    font-weight: 600;
    color: var(--tblr-primary);
}

.assistant-fill-note-warnings {
    margin: 0.375rem 0 0;
    padding-left: 1.25rem;
    color: #8a5300;
}

.form-control.assistant-filled,
.form-select.assistant-filled {
    border-color: var(--tblr-primary);
    background-color: rgba(6, 111, 209, 0.06);
    box-shadow: 0 0 0 0.2rem rgba(6, 111, 209, 0.15);
}

.assistant-composer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}

.assistant-mic {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    flex-shrink: 0;
}

.assistant-mic-listening {
    animation: assistant-pulse 1s ease-in-out infinite;
}

@keyframes assistant-pulse {
    50% {
        box-shadow: 0 0 0 0.5rem rgba(6, 111, 209, 0.25);
    }
}

.assistant-status {
    margin: 0;
    padding: 0 0.75rem 0.625rem;
    font-size: 0.8125rem;
    color: var(--tblr-secondary);
    background: var(--tblr-bg-surface);
}

.assistant-status:empty {
    display: none;
}

@media (max-width: 767.98px) {
    .has-tabbar .assistant-fab {
        bottom: calc(4.75rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 575.98px) {
    .assistant-fab {
        right: 1rem;
    }

    .assistant-panel {
        inset: 0;
        width: auto;
        height: auto;
        border: 0;
        border-radius: 0;
    }

    .assistant-open .assistant-fab {
        display: none;
    }

    .assistant-composer {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
}

/* The page underneath doesn't scroll while the assistant fills a phone's screen. */
@media (max-width: 575.98px) {
    body.assistant-open {
        overflow: hidden;
    }
}

/* On a phone, the end of the page scrolls clear of the assistant button sitting above the tab bar. */
@media (max-width: 767.98px) {
    .has-tabbar:has(.assistant-fab) .page-body {
        padding-bottom: calc(9rem + env(safe-area-inset-bottom));
    }
}
