/*
 * App shell polish shared by every company.
 * Colors come from --ui-primary: the default (Empire) gold, or the CSS_THEME brand color (teegee orange),
 * so each company keeps its own palette and only the feel changes.
 */
:root {
    --ui-primary: #c0a145;
    --ui-primary-rgb: 192, 161, 69;
    --ui-radius: 12px;
    --ui-radius-sm: 8px;
    --ui-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ui-skeleton: rgba(127, 127, 127, 0.14);
    --ui-skeleton-shine: rgba(127, 127, 127, 0.26);
}

html[data-css-theme="teegee"] {
    --ui-primary: var(--tg-primary);
    --ui-primary-rgb: var(--tg-primary-rgb);
}

/* ---------- Smooth page-to-page navigation (browsers without support simply skip it) ---------- */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.18s;
    animation-timing-function: var(--ui-ease);
}

/* Sidebar and header stay still while only the page content changes. */
.dash-sidebar {
    view-transition-name: app-sidebar;
}

.dash-header {
    view-transition-name: app-header;
}

.dash-container .dash-content {
    animation: ui-enter 0.28s var(--ui-ease) both;
}

@keyframes ui-enter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* The old full-screen pre-loader flashes on every page; the top progress bar replaces it. */
.loader-bg {
    display: none !important;
}

/* ---------- Top progress bar ---------- */
#nprogress {
    pointer-events: none;
}

#nprogress .bar {
    background: var(--ui-primary);
    height: 3px;
    z-index: 100000;
}

#nprogress .peg {
    box-shadow: 0 0 10px var(--ui-primary), 0 0 5px var(--ui-primary);
}

#nprogress .spinner {
    display: none;
}

/* ---------- Brand loader for slow page changes (ui-shell.js shows it after 350 ms) ---------- */
.ui-nav-loader {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(12, 12, 14, 0.22);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s var(--ui-ease), visibility 0.2s var(--ui-ease);
}

.ui-nav-loader.is-visible {
    opacity: 1;
    visibility: visible;
}

.ui-nav-loader__ring {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 3px solid rgba(var(--ui-primary-rgb), 0.2);
    border-top-color: var(--ui-primary);
    box-shadow: 0 0 28px rgba(var(--ui-primary-rgb), 0.35);
    animation: ui-spin 0.75s linear infinite;
}

@keyframes ui-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Cards, buttons, inputs ---------- */
.dash-content .card {
    border-radius: var(--ui-radius);
    transition: box-shadow 0.2s var(--ui-ease);
}

.btn {
    transition: background-color 0.15s var(--ui-ease), border-color 0.15s var(--ui-ease), box-shadow 0.15s var(--ui-ease), transform 0.1s var(--ui-ease);
}

.btn:active {
    transform: scale(0.97);
}

.form-control,
.form-select {
    transition: border-color 0.15s var(--ui-ease), box-shadow 0.15s var(--ui-ease);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ui-primary);
    box-shadow: 0 0 0 3px rgba(var(--ui-primary-rgb), 0.2);
}

.action-btn {
    transition: transform 0.12s var(--ui-ease), filter 0.12s var(--ui-ease);
}

.action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

/* ---------- Avatar with initial fallback (shown when there is no photo or it fails to load) ---------- */
.ui-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 50%;
    background: rgba(var(--ui-primary-rgb), 0.15);
    color: var(--ui-primary);
    font-weight: 600;
    font-size: 14px;
}

.ui-avatar::before {
    content: attr(data-initial);
}

.ui-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- DataTables ---------- */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--ui-radius-sm);
    padding: 6px 12px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--ui-radius-sm) !important;
    transition: background-color 0.15s var(--ui-ease);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--ui-primary) !important;
    border-color: var(--ui-primary) !important;
    color: #fff !important;
}

table.dataTable tbody tr {
    transition: background-color 0.15s var(--ui-ease);
}

/* The "Processing..." box is replaced by skeleton rows (see ui-shell.js). */
.dataTables_wrapper .dataTables_processing {
    display: none !important;
}

table.dataTable.ui-loading tbody td {
    position: relative;
    color: transparent !important;
}

table.dataTable.ui-loading tbody td > * {
    visibility: hidden;
}

table.dataTable.ui-loading tbody td::after {
    content: "";
    position: absolute;
    inset: 30% 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--ui-skeleton) 25%, var(--ui-skeleton-shine) 50%, var(--ui-skeleton) 75%);
    background-size: 200% 100%;
    animation: ui-shimmer 1.1s linear infinite;
}

.ui-skeleton-row td {
    height: 52px;
}

@keyframes ui-shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* ---------- Toasts ---------- */
#liveToast {
    border-radius: var(--ui-radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

#liveToast.show {
    animation: ui-toast-in 0.25s var(--ui-ease) both;
}

@keyframes ui-toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dash-container .dash-content,
    #liveToast.show,
    table.dataTable.ui-loading tbody td::after {
        animation: none;
    }

    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none;
    }
}

/* Sidebar collapse button (partials/header): hidden unless the active theme styles it (default theme, teegee). */
.tg-sidebar-toggle {
    display: none;
}
