/* EasyRP shell + shared UI styles (Bootstrap 5.3 companion).
 *
 * The --easyrp-* custom-property contract lives in theme.css (Agent A), which
 * MUST load before this file. Everything here consumes those variables so the
 * whole shell re-themes across the 12 curated themes + density modes. No
 * hard-coded colours below — only var(--easyrp-*) references. */

/* --- Login ------------------------------------------------------------- */

.easyrp-login-body {
    background: linear-gradient(160deg, var(--easyrp-topbar-bg) 0%, var(--easyrp-accent) 100%);
}

.easyrp-login-card {
    width: 100%;
    max-width: 380px;
    border: 0;
    border-radius: 0.75rem;
    background-color: var(--easyrp-surface);
    color: var(--easyrp-text);
}

.easyrp-brand-mark {
    font-size: 2.5rem;
    color: var(--easyrp-accent);
}

/* --- Shell layout ------------------------------------------------------- */

.easyrp-shell-body {
    background-color: var(--easyrp-bg);
    color: var(--easyrp-text);
    min-height: 100vh;
}

.easyrp-topbar {
    background-color: var(--easyrp-topbar-bg);
    color: var(--easyrp-topbar-text);
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 52px;
}

.easyrp-layout {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 52px);
}

.easyrp-sidebar {
    width: var(--easyrp-sidebar-width);
    flex: 0 0 var(--easyrp-sidebar-width);
    background-color: var(--easyrp-sidebar-bg);
    border-right: 1px solid var(--easyrp-border);
}

.easyrp-main {
    flex: 1 1 auto;
    min-width: 0;
}

/* --- Sidebar menu -------------------------------------------------------- */

.easyrp-menu-link {
    color: var(--easyrp-text);
    padding: var(--easyrp-density-pad) 1rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.easyrp-menu-link:hover {
    background-color: var(--easyrp-accent-weak);
    color: var(--easyrp-accent);
}

.easyrp-menu-link.active {
    background-color: var(--easyrp-accent-weak);
    border-left-color: var(--easyrp-accent);
    color: var(--easyrp-accent);
    font-weight: 600;
}

.easyrp-menu-link i {
    color: var(--easyrp-accent);
}

/* --- Shared components (ui.js) ------------------------------------------- */

.easyrp-typeahead-menu {
    max-height: 320px;
    overflow-y: auto;
    top: 100%;
    left: 0;
}

th.easyrp-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.easyrp-sortable::after {
    content: "\2195";           /* ↕ */
    opacity: 0.35;
    margin-left: 0.3rem;
    font-size: 0.8em;
}

th.easyrp-sortable[data-sort-dir="asc"]::after {
    content: "\2191";           /* ↑ */
    opacity: 1;
}

th.easyrp-sortable[data-sort-dir="desc"]::after {
    content: "\2193";           /* ↓ */
    opacity: 1;
}

.easyrp-table-sticky thead th {
    position: sticky;
    top: 52px;                  /* below the fixed topbar */
    background-color: var(--easyrp-surface);
    z-index: 5;
    box-shadow: 0 1px 0 var(--easyrp-border);
}

/* --- Sidebar section headers (S7) ---------------------------------------- */

.easyrp-menu-section {
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    color: var(--easyrp-text-muted);
}

.easyrp-menu-section:first-child {
    padding-top: 0.5rem !important;
}

/* --- Global search results (S15) ----------------------------------------- */

.easyrp-search-results {
    max-height: 70vh;
    overflow-y: auto;
}

/* --- Dashboard KPI tiles ------------------------------------------------- */

.easyrp-kpi {
    border-left: 4px solid var(--easyrp-accent) !important;
}

.easyrp-kpi .card-body {
    padding: var(--easyrp-density-pad) 1rem;
}

/* --- Mobile: sidebar becomes an offcanvas (S6) --------------------------- */

@media (max-width: 767.98px) {
    /* Bootstrap offcanvas-md drives the show/hide; just size it. */
    .easyrp-sidebar.offcanvas-md {
        --bs-offcanvas-width: 260px;
    }
}

/* --- Dark-theme legibility safeguard ------------------------------------- */
/* A few pre-existing pages hard-code .bg-white on card headers. In a dark
   theme that leaves light text on a white surface (unreadable). Re-tint those
   surfaces to the theme surface inside the app content area — non-destructive,
   only active under a dark theme. */

[data-bs-theme="dark"] .easyrp-main .bg-white {
    background-color: var(--easyrp-surface) !important;
    color: var(--easyrp-text);
}

/* --- Preferences page: theme gallery cards (preferences.jsp) -------------- */

.easyrp-theme-card {
    display: block;
    width: 100%;
    border: 1px solid var(--easyrp-border);
    border-radius: var(--easyrp-radius);
    background-color: var(--easyrp-surface);
    color: var(--easyrp-text);
    padding: 0.5rem;
    text-align: left;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.easyrp-theme-card:hover {
    border-color: var(--easyrp-accent);
    box-shadow: var(--easyrp-shadow);
    transform: translateY(-1px);
}

.easyrp-theme-card.active {
    border-color: var(--easyrp-accent);
    box-shadow: 0 0 0 2px var(--easyrp-accent-weak), var(--easyrp-shadow);
}

.easyrp-theme-swatch {
    position: relative;
    height: 66px;
    border-radius: calc(var(--easyrp-radius) - 0.15rem);
    border: 1px solid var(--easyrp-border);
    overflow: hidden;
}

.easyrp-theme-swatch .easyrp-swatch-topbar {
    height: 16px;
    width: 100%;
}

.easyrp-theme-swatch .easyrp-swatch-body {
    position: absolute;
    inset: 16px 0 0 0;
    padding: 8px;
}

.easyrp-theme-swatch .easyrp-swatch-panel {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
}

.easyrp-theme-swatch .easyrp-swatch-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.easyrp-theme-swatch .easyrp-swatch-line {
    height: 6px;
    border-radius: 3px;
    flex: 1 1 auto;
    opacity: 0.65;
}

.easyrp-theme-card-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.easyrp-theme-card-name .easyrp-theme-check {
    color: var(--easyrp-accent);
    opacity: 0;
}

.easyrp-theme-card.active .easyrp-theme-check {
    opacity: 1;
}

.easyrp-theme-family-tag {
    font-size: 0.68rem;
    color: var(--easyrp-text-muted);
    font-weight: 400;
}

@media (prefers-reduced-motion: reduce) {
    .easyrp-theme-card {
        transition: none;
    }
    .easyrp-theme-card:hover {
        transform: none;
    }
}
