/*
 * RAS Jobs additions on top of the RAS Basic theme.
 */

/* ---------------------------------------------------------------------------
 * Skeleton loading placeholders
 * Used by <x-skeleton.*> components while async panels and paged lists load.
 * ------------------------------------------------------------------------- */
.skeleton {
    --skeleton-base: #e6e6e6;
    --skeleton-shine: #f4f4f4;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 37%, var(--skeleton-base) 63%);
    background-size: 400% 100%;
    border-radius: 0.375rem;
    display: block;
}

[data-theme="dark"] .skeleton {
    --skeleton-base: #2c3035;
    --skeleton-shine: #3a3f45;
}

.skeleton-line {
    height: 0.85rem;
    margin-bottom: 0.55rem;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-heading {
    height: 1.35rem;
    margin-bottom: 0.9rem;
}

.skeleton-number {
    height: 2.1rem;
    width: 3.5rem;
}

.skeleton-pill {
    border-radius: 999px;
    height: 1.25rem;
    width: 5rem;
}

.skeleton-table td {
    padding-block: 0.85rem;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

.async-panel-error {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
}

/* ---------------------------------------------------------------------------
 * HR dashboard
 * Skeleton and loaded states share the same grid so nothing shifts on swap.
 * ------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.stat-card {
    color: inherit;
    display: block;
    height: 100%;
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

a.stat-card:hover {
    border-color: var(--ras-red);
    color: inherit;
    transform: translateY(-1px);
}

.stat-card .card-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 6.5rem;
}

.stat-label {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.stat-count {
    font-size: 2rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1;
    margin-top: auto;
}

.breakdown-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.breakdown-list .list-group-item {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

/* Area section headers (applicant / HR). */
.area-header {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.area-header h1 {
    margin-bottom: 0.25rem;
}

/* Text takes the remaining width; buttons stay top-right and only drop
   below the text on narrow screens. */
.area-header-text {
    flex: 1 1 20rem;
    min-width: 0;
}

.area-header-actions {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-left: auto;
}

/* ---------------------------------------------------------------------------
 * Drag-and-drop row ordering (public/js/sortable-rows.js)
 * ------------------------------------------------------------------------- */
.drag-col {
    width: 2.5rem;
}

.drag-handle {
    display: inline-block;
    user-select: none;
    background: transparent;
    border: 0;
    border-radius: 0.375rem;
    color: #8a8a8a;
    cursor: grab;
    font-size: 1.1rem;
    letter-spacing: -0.2em;
    line-height: 1;
    padding: 0.35rem 0.5rem 0.35rem 0.3rem;
    touch-action: none;
}

.drag-handle:hover {
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
}

.drag-handle:focus-visible {
    outline: 2px solid var(--ras-red);
    outline-offset: 1px;
}

.drag-handle:active {
    cursor: grabbing;
}

[data-theme="dark"] .drag-handle:hover {
    background: rgba(255, 255, 255, 0.08);
}

tr.sortable-ghost > td {
    background: var(--ras-red-light);
    opacity: 0.6;
}

[data-theme="dark"] tr.sortable-ghost > td {
    background: #3a2326;
}

tr.sortable-chosen > td {
    background: rgba(143, 24, 32, 0.06);
}

.sortable-status {
    min-height: 1.25rem;
}

/* Inline add/edit panels (public/js/inline-forms.js) */
.inline-edit-row > td {
    background: rgba(143, 24, 32, 0.04);
    border-left: 3px solid var(--ras-red);
    padding: 1rem 1rem 1.1rem;
}

[data-theme="dark"] .inline-edit-row > td {
    background: rgba(255, 255, 255, 0.04);
}

#add-panel {
    border-left: 3px solid var(--ras-red);
}

/* ---------------------------------------------------------------------------
 * Employment application (applicant)
 * ------------------------------------------------------------------------- */
.application-layout {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 992px) {
    .application-layout {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .application-progress {
        align-self: start;
        position: sticky;
        top: 1rem;
    }
}

.step-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.step-list-item a {
    align-items: center;
    border-radius: 0.5rem;
    color: inherit;
    display: flex;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    text-decoration: none;
}

.step-list-item a:hover {
    background: rgba(0, 0, 0, 0.04);
}

.step-list-item.is-current a {
    background: var(--ras-red-light);
    font-weight: 600;
}

[data-theme="dark"] .step-list-item.is-current a {
    background: #3a2326;
}

.step-list-marker {
    align-items: center;
    border: 1px solid var(--ras-gray-border);
    border-radius: 999px;
    display: inline-flex;
    flex: 0 0 1.6rem;
    font-size: 0.75rem;
    height: 1.6rem;
    justify-content: center;
}

.step-list-item.is-complete .step-list-marker {
    background: #198754;
    border-color: #198754;
    color: #fff;
}

.step-list-item.is-incomplete .step-list-marker {
    background: #ffc107;
    border-color: #ffc107;
    color: #212529;
    font-weight: 700;
}

.step-list-label {
    font-size: 0.92rem;
    line-height: 1.25;
}

.application-actions {
    align-items: center;
    border-top: 1px solid var(--ras-gray-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.choice-grid {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.choice-tile {
    align-items: flex-start;
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
}

.choice-tile:has(input:checked) {
    background: var(--ras-red-light);
    border-color: var(--ras-red);
}

[data-theme="dark"] .choice-tile:has(input:checked) {
    background: #3a2326;
}

.choice-tile:has(input:focus-visible) {
    outline: 2px solid var(--ras-red);
    outline-offset: 1px;
}

.choice-tile.is-invalid {
    border-color: #dc3545;
}

.skill-list {
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.5rem;
}

.skill-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.6rem 0.9rem;
}

.skill-row + .skill-row {
    border-top: 1px solid var(--ras-gray-border);
}

.skill-row.is-selected {
    background: rgba(143, 24, 32, 0.04);
}

.skill-years {
    width: 9rem;
}

.question-follow-up {
    border-left: 3px solid var(--ras-gray-border);
    padding-left: 0.9rem;
}

.review-list dt {
    color: #5a5a5a;
    font-weight: 500;
}

[data-theme="dark"] .review-list dt {
    color: #adb5bd;
}

.certification-text {
    max-height: 18rem;
    overflow-y: auto;
}

.signature-input {
    font-family: "Brush Script MT", "Segoe Script", cursive;
    font-size: 1.35rem;
}

/* ---------------------------------------------------------------------------
 * HR candidate detail
 * ------------------------------------------------------------------------- */
.candidate-layout {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 992px) {
    .candidate-layout {
        grid-template-columns: minmax(0, 1fr) 340px;
    }
}

.timeline {
    border-left: 2px solid var(--ras-gray-border);
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.9rem;
}

.timeline > li {
    margin-bottom: 0.75rem;
    position: relative;
}

.timeline > li::before {
    background: var(--ras-red);
    border-radius: 999px;
    content: "";
    height: 0.55rem;
    left: -1.22rem;
    position: absolute;
    top: 0.4rem;
    width: 0.55rem;
}

.hr-note {
    border-bottom: 1px solid var(--ras-gray-border);
    padding: 0.6rem 0;
}

.hr-note:first-child {
    padding-top: 0;
}

.hr-note-body {
    white-space: pre-line;
}

.hr-note-reply {
    border-bottom: 0;
    border-left: 3px solid var(--ras-gray-border);
    margin-left: 0.5rem;
    margin-top: 0.4rem;
    padding: 0.25rem 0 0.25rem 0.75rem;
}

.signature-display {
    font-family: "Brush Script MT", "Segoe Script", cursive;
    font-size: 1.3rem;
}

@media print {
    @page {
        margin: 0.5in;
    }

    body,
    .site-body {
        background: #fff !important;
    }

    .site-header,
    .site-footer,
    .no-print,
    .toast {
        display: none !important;
    }

    .site-content > .container-shell {
        max-width: none;
        padding: 0 !important;
    }

    .candidate-layout {
        display: block;
    }

    /* Long cards may continue on the next page; small units stay together. */
    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        margin-bottom: 0.75rem !important;
    }

    .card-header {
        background: none !important;
        border-bottom: 1px solid #ccc !important;
        font-weight: 700;
    }

    .candidate-header,
    .candidate-sidebar .card,
    .review-list dt,
    .review-list dd,
    .document-row,
    .hr-note,
    .timeline > li {
        break-inside: avoid;
    }

    h1, h2, h3,
    .print-panel-title {
        break-after: avoid;
    }

    a {
        color: inherit !important;
        text-decoration: none !important;
    }

    .certification-text {
        max-height: none;
        overflow: visible;
    }

    .print-only {
        display: block !important;
    }

    /*
     * Candidate record order: header, application, documents, certification,
     * status / considering, then internal notes on their own last page.
     * display: contents lets the notes panel be ordered after the sidebar.
     */
    .candidate-layout {
        display: flex;
        flex-direction: column;
    }

    .candidate-main,
    .candidate-main > .tab-card {
        display: contents;
    }

    .candidate-main > .tab-card > .tab-panel {
        border: 1px solid #ccc;
        border-radius: 0.375rem;
        margin-bottom: 0.75rem;
    }

    .candidate-sidebar {
        order: 1;
    }

    .candidate-main #notes {
        break-before: page;
        order: 2;
    }

    .print-without-notes .candidate-main #notes {
        display: none !important;
    }
}

.print-only {
    display: none;
}

.print-notes-excluded {
    display: none;
}

.print-without-notes .print-notes-excluded {
    display: inline;
}

.print-panel-title {
    border-bottom: 2px solid #333;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
}

.print-meta {
    color: #555;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

/* ---------------------------------------------------------------------------
 * Status badges (<x-status-badge>). Soft background + dark text keeps
 * contrast above 4.5:1 in both themes.
 * ------------------------------------------------------------------------- */
.status-badge {
    --status-bg: #eceff1;
    --status-fg: #37474f;
    --status-dot: #78909c;
    align-items: center;
    background: var(--status-bg);
    border-radius: 999px;
    color: var(--status-fg);
    display: inline-flex;
    font-size: 0.8rem;
    font-weight: 600;
    gap: 0.4rem;
    line-height: 1.2;
    padding: 0.3rem 0.7rem;
    white-space: nowrap;
}

.status-badge-lg {
    font-size: 1rem;
    padding: 0.45rem 0.95rem;
}

.status-dot {
    background: var(--status-dot);
    border-radius: 999px;
    display: inline-block;
    flex: 0 0 auto;
    height: 0.5rem;
    width: 0.5rem;
}

.status-blue { --status-bg: #e3f0fd; --status-fg: #0b4a8b; --status-dot: #1a73e8; }
.status-teal { --status-bg: #dff5f2; --status-fg: #0b5c54; --status-dot: #13a393; }
.status-green { --status-bg: #e3f4e8; --status-fg: #1b5e2f; --status-dot: #2e9e4f; }
.status-amber { --status-bg: #fdf1d8; --status-fg: #7a4b00; --status-dot: #e0a100; }
.status-red { --status-bg: #fbe4e6; --status-fg: #8f1820; --status-dot: #d93a47; }
.status-purple { --status-bg: #efe7fb; --status-fg: #4b2a8a; --status-dot: #8250df; }

[data-theme="dark"] .status-badge { --status-bg: #2f3439; --status-fg: #d6dbe0; --status-dot: #9aa5b1; }
[data-theme="dark"] .status-blue { --status-bg: #13304f; --status-fg: #b9d9ff; --status-dot: #5aa2ff; }
[data-theme="dark"] .status-teal { --status-bg: #113c38; --status-fg: #a8ece2; --status-dot: #3cc9b5; }
[data-theme="dark"] .status-green { --status-bg: #173a22; --status-fg: #b5e7c3; --status-dot: #4cc46f; }
[data-theme="dark"] .status-amber { --status-bg: #3d2e0b; --status-fg: #fbdc98; --status-dot: #f0b429; }
[data-theme="dark"] .status-red { --status-bg: #45181c; --status-fg: #ffc3c8; --status-dot: #ff6b77; }
[data-theme="dark"] .status-purple { --status-bg: #2e2248; --status-fg: #dccbff; --status-dot: #a984f5; }

.color-choice {
    cursor: pointer;
    display: inline-flex;
}

.color-choice input {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.color-choice input:checked + .status-badge {
    box-shadow: 0 0 0 2px var(--ras-red);
}

.color-choice input:focus-visible + .status-badge {
    outline: 2px solid var(--ras-red);
    outline-offset: 2px;
}

@media print {
    .status-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Document lists (applicant documents, HR candidate page) */
.document-row {
    align-items: center;
    border-bottom: 1px solid var(--ras-gray-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.7rem 0;
}

.document-row:last-of-type {
    border-bottom: 0;
}

.document-icon {
    align-items: center;
    background: var(--ras-red-light);
    border-radius: 0.4rem;
    color: var(--ras-red-dark);
    display: inline-flex;
    flex: 0 0 2.6rem;
    font-size: 0.65rem;
    font-weight: 700;
    height: 2.6rem;
    justify-content: center;
}

[data-theme="dark"] .document-icon {
    background: #3a2326;
    color: #ffc3c8;
}

.document-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.min-w-0 {
    min-width: 0;
}

/* ---------------------------------------------------------------------------
 * Brand-colored checkboxes, radios and switches (app-wide)
 * ------------------------------------------------------------------------- */
.form-check-input:checked {
    background-color: var(--ras-red);
    border-color: var(--ras-red);
}

.form-check-input:focus {
    border-color: var(--ras-red);
    box-shadow: 0 0 0 0.2rem var(--ras-focus-ring);
}

.form-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%238f1820'/%3e%3c/svg%3e");
}

/* ---------------------------------------------------------------------------
 * Account settings
 * ------------------------------------------------------------------------- */
.account-avatar {
    align-items: center;
    background: var(--ras-red);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 3.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    height: 3.5rem;
    justify-content: center;
    letter-spacing: 0.02em;
}

.account-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.75rem;
}

.account-facts dt {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.account-facts dd {
    margin: 0;
}

.tab-strip {
    background: rgba(0, 0, 0, 0.025);
    border-bottom: 1px solid var(--ras-gray-border);
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0 0.75rem;
    scrollbar-width: none;
}

[data-theme="dark"] .tab-strip {
    background: rgba(255, 255, 255, 0.03);
}

.tab-strip::-webkit-scrollbar {
    display: none;
}

.tab-strip [role="tab"] {
    border-bottom: 3px solid transparent;
    color: inherit;
    flex: 0 0 auto;
    font-weight: 600;
    margin-bottom: -1px;
    padding: 0.85rem 0.9rem 0.75rem;
    text-decoration: none;
    white-space: nowrap;
}

.tab-strip [role="tab"]:hover {
    border-bottom-color: var(--ras-gray-border);
    color: var(--ras-red);
}

.tab-strip [role="tab"].active {
    border-bottom-color: var(--ras-red);
    color: var(--ras-red);
}

.tab-strip [role="tab"]:focus-visible {
    border-radius: 0.375rem 0.375rem 0 0;
    outline: 2px solid var(--ras-red);
    outline-offset: -2px;
}

[data-theme="dark"] .tab-strip [role="tab"].active,
[data-theme="dark"] .tab-strip [role="tab"]:hover {
    color: #ff8f99;
}

[data-theme="dark"] .tab-strip [role="tab"].active {
    border-bottom-color: #ff8f99;
}

/* Without JavaScript the tabs act as jump links and every section shows. */
.tab-card:not(.tabs-ready) .tab-strip [role="tab"] {
    border-bottom-color: transparent;
}

.account-section {
    scroll-margin-top: 1rem;
}

/* Without JavaScript all sections show inside the card, separated by rules. */
.tab-panel + .tab-panel {
    border-top: 1px solid var(--ras-gray-border);
}

.tab-card.tabs-ready .tab-panel + .tab-panel {
    border-top: 0;
}

.account-section > .card-body {
    display: grid;
    gap: 1rem 2rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 992px) {
    .account-section > .card-body {
        grid-template-columns: 260px minmax(0, 1fr);
        padding: 1.5rem;
    }
}

.account-section-intro h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.account-section-intro p {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.account-always {
    border-left: 3px solid var(--ras-gray-border);
    color: #6c757d;
    font-size: 0.85rem;
    padding-left: 0.75rem;
}

.account-always ul {
    margin: 0.2rem 0 0;
    padding-left: 1rem;
}

.account-section-body {
    max-width: 640px;
}

.account-toggles {
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.5rem;
}

.account-toggle {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.8rem 1rem;
}

.account-toggle + .account-toggle {
    border-top: 1px solid var(--ras-gray-border);
}

.account-toggle .form-check-input {
    cursor: pointer;
    height: 1.4rem;
    margin: 0;
    width: 2.6rem;
}

.account-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* Selectable chips (filters). */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    cursor: pointer;
    position: relative;
}

.chip input {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.chip span {
    align-items: center;
    border: 1px solid var(--ras-gray-border);
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.9rem;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chip span:hover {
    border-color: var(--ras-red);
}

.chip input:checked + span {
    background: var(--ras-red-light);
    border-color: var(--ras-red);
    color: var(--ras-red-dark);
    font-weight: 600;
}

.chip input:checked + span::before {
    content: "\2713";
}

.chip input:focus-visible + span {
    outline: 2px solid var(--ras-red);
    outline-offset: 2px;
}

[data-theme="dark"] .chip input:checked + span {
    background: #3a2326;
    color: #ffc3c8;
}

[data-theme="dark"] .account-facts dt,
[data-theme="dark"] .account-section-intro p,
[data-theme="dark"] .account-always {
    color: #adb5bd;
}

/* Tab panels receive focus programmatically; no outline on the whole card. */
[role="tabpanel"]:focus {
    outline: none;
}

/* Tab counts and print behaviour for tabbed cards. */
.tab-count {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    font-size: 0.75rem;
    margin-left: 0.3rem;
    padding: 0.05rem 0.45rem;
}

[data-theme="dark"] .tab-count {
    background: rgba(255, 255, 255, 0.12);
}

.tab-strip [role="tab"].active .tab-count {
    background: var(--ras-red-light);
}

@media print {
    .tab-strip {
        display: none !important;
    }

    .tab-panel[hidden] {
        display: block !important;
    }

    .tab-panel.no-print {
        display: none !important;
    }
}

/* Application answers inside a tab: sections without their own card chrome. */
.review-section-flat + .review-section-flat {
    border-top: 1px solid var(--ras-gray-border);
    margin-top: 1.25rem;
    padding-top: 1.25rem;
}

.review-section-flat h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

/* Thank-you card after an application is submitted. */
.submitted-card {
    border-left: 4px solid #2e9e4f;
}

.submitted-check {
    align-items: center;
    background: #e3f4e8;
    border-radius: 999px;
    color: #1b5e2f;
    display: inline-flex;
    flex: 0 0 3.25rem;
    font-size: 1.6rem;
    font-weight: 700;
    height: 3.25rem;
    justify-content: center;
}

[data-theme="dark"] .submitted-check {
    background: #173a22;
    color: #b5e7c3;
}

@media (prefers-reduced-motion: no-preference) {
    .submitted-card {
        animation: submitted-pop 0.45s ease-out;
    }

    @keyframes submitted-pop {
        from {
            opacity: 0;
            transform: translateY(-6px) scale(0.98);
        }
    }
}

.color-swatch {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    display: inline-block;
    height: 0.7rem;
    margin-right: -0.2rem;
    width: 0.7rem;
}

/* Tab strip in the middle of a card (below a page heading). */
.tab-strip-inset {
    border-top: 1px solid var(--ras-gray-border);
}

/* Show/hide password button (<x-form.password>). */
.password-toggle {
    align-items: center;
    display: inline-flex;
    padding-inline: 0.7rem;
}

.password-toggle .icon-hide,
.password-toggle.is-visible .icon-show {
    display: none;
}

.password-toggle.is-visible .icon-hide {
    display: inline;
}

.password-field .form-control.is-invalid {
    z-index: 0;
}

/* Cards stacked in a column fill its width (RAS Basic's .dashboard-card
   uses align-self: start, which shrinks cards to their content). */
.card-stack > .card {
    align-self: stretch;
}

/* Appearance choices (account page). */
.theme-choices {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.theme-choice {
    cursor: pointer;
    position: relative;
}

.theme-choice input {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.theme-choice-card {
    border: 2px solid var(--ras-gray-border);
    border-radius: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    height: 100%;
    padding: 0.75rem;
    transition: border-color 0.15s ease;
}

.theme-choice:hover .theme-choice-card {
    border-color: #b9b9b9;
}

.theme-choice input:checked + .theme-choice-card {
    border-color: var(--ras-red);
    box-shadow: 0 0 0 3px var(--ras-focus-ring);
}

.theme-choice input:focus-visible + .theme-choice-card {
    outline: 2px solid var(--ras-red);
    outline-offset: 2px;
}

.theme-choice-label {
    font-weight: 700;
}

.theme-choice input:checked + .theme-choice-card .theme-choice-label::after {
    color: var(--ras-red);
    content: " \2713";
}

.theme-choice-hint {
    color: #6c757d;
    font-size: 0.82rem;
}

[data-theme="dark"] .theme-choice-hint {
    color: #adb5bd;
}

/* Miniature page: header bar, content line, content block. */
.theme-preview {
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 0.4rem;
    display: grid;
    gap: 0.3rem;
    grid-template-rows: 0.5rem 0.35rem 1.2rem;
    height: 4rem;
    margin-bottom: 0.4rem;
    overflow: hidden;
    padding: 0.4rem;
}

.theme-preview span {
    border-radius: 0.2rem;
}

.theme-preview span:first-child {
    background: #8f1820;
}

.theme-preview-light {
    background: #f5f5f5;
}

.theme-preview-light span:not(:first-child) {
    background: #ffffff;
    border: 1px solid #dddddd;
}

.theme-preview-dark {
    background: #16181b;
}

.theme-preview-dark span:not(:first-child) {
    background: #24272b;
    border: 1px solid #33373c;
}

.theme-preview-system {
    background: linear-gradient(135deg, #f5f5f5 50%, #16181b 50%);
}

.theme-preview-system span:not(:first-child) {
    background: linear-gradient(135deg, #ffffff 50%, #24272b 50%);
    border: 1px solid #9a9a9a;
}

/* ---------------------------------------------------------------------------
 * Tags: small labels that stay readable in light and dark themes
 * (RAS Basic's dark CSS makes .text-dark near-white and .bg-light near-black,
 * which breaks Bootstrap's light badge combinations).
 * ------------------------------------------------------------------------- */
.tag {
    --tag-bg: #f1f3f5;
    --tag-fg: #343a40;
    --tag-border: #dee2e6;
    align-items: center;
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
    border-radius: 999px;
    color: var(--tag-fg);
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.22rem 0.6rem;
    white-space: nowrap;
}

.tag-brand { --tag-bg: #fbe4e6; --tag-fg: #8f1820; --tag-border: #f2c4c9; }
.tag-amber { --tag-bg: #fdf1d8; --tag-fg: #7a4b00; --tag-border: #f3dca8; }
.tag-blue { --tag-bg: #e3f0fd; --tag-fg: #0b4a8b; --tag-border: #c4dcf6; }

[data-theme="dark"] .tag { --tag-bg: #2a2e33; --tag-fg: #e3e6ea; --tag-border: #3d4248; }
[data-theme="dark"] .tag-brand { --tag-bg: #45181c; --tag-fg: #ffc3c8; --tag-border: #6a2a30; }
[data-theme="dark"] .tag-amber { --tag-bg: #3d2e0b; --tag-fg: #fbdc98; --tag-border: #5c4612; }
[data-theme="dark"] .tag-blue { --tag-bg: #13304f; --tag-fg: #b9d9ff; --tag-border: #22476f; }

@media print {
    .tag {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ---------------------------------------------------------------------------
 * Light theme: Rev-A-Shelf red instead of Bootstrap blue for primary buttons
 * in every state (hover, pressed, focus, disabled), outline buttons, menus
 * and progress bars. Dark theme colors come from app-dark.css.
 * ------------------------------------------------------------------------- */
[data-theme="light"] .btn-primary {
    --bs-btn-bg: var(--ras-red);
    --bs-btn-border-color: var(--ras-red);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--ras-red-dark);
    --bs-btn-hover-border-color: var(--ras-red-dark);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--ras-red-darker);
    --bs-btn-active-border-color: var(--ras-red-darker);
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-bg: var(--ras-red);
    --bs-btn-disabled-border-color: var(--ras-red);
    --bs-btn-disabled-color: #fff;
    --bs-btn-focus-shadow-rgb: 143, 24, 32;
}

[data-theme="light"] .btn-outline-primary {
    --bs-btn-color: var(--ras-red);
    --bs-btn-border-color: var(--ras-red);
    --bs-btn-hover-bg: var(--ras-red);
    --bs-btn-hover-border-color: var(--ras-red);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--ras-red-dark);
    --bs-btn-active-border-color: var(--ras-red-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-color: var(--ras-red);
    --bs-btn-disabled-border-color: var(--ras-red);
    --bs-btn-focus-shadow-rgb: 143, 24, 32;
}

[data-theme="light"] .btn-primary:active,
[data-theme="light"] .btn-primary.active,
[data-theme="light"] .btn-primary:disabled,
[data-theme="light"] .btn-primary.disabled {
    background-color: var(--bs-btn-active-bg);
    border-color: var(--bs-btn-active-border-color);
}

[data-theme="light"] .btn-primary:disabled,
[data-theme="light"] .btn-primary.disabled {
    background-color: var(--ras-red);
    border-color: var(--ras-red);
}

[data-theme="light"] .dropdown-menu {
    --bs-dropdown-link-active-bg: var(--ras-red);
    --bs-dropdown-link-active-color: #fff;
}

[data-theme="light"] .progress {
    --bs-progress-bar-bg: var(--ras-red);
}

/* ---------------------------------------------------------------------------
 * Cookie notice (<x-cookie-notice>). Class names avoid "cookie" so browser
 * cookie-banner filters (e.g. Brave Shields) do not hide it.
 * ------------------------------------------------------------------------- */
.ras-notice-overlay {
    background: rgba(0, 0, 0, 0.55);
    inset: 0;
    position: fixed;
    z-index: 1080;
}

.ras-notice {
    background: var(--bs-body-bg, #fff);
    border-top: 4px solid var(--ras-red);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
    color: var(--bs-body-color, #212529);
    padding: 1rem 1.25rem;
    z-index: 1090;
}

.ras-notice-inner {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    justify-content: space-between;
    margin-inline: auto;
    max-width: var(--layout-max-width, 1200px);
}

.ras-notice:not(.is-preview) {
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
}

.ras-notice--required:not(.is-preview) {
    border: 0;
    border-radius: 0.75rem;
    border-top: 4px solid var(--ras-red);
    bottom: 50%;
    left: 50%;
    max-width: min(560px, calc(100vw - 2rem));
    right: auto;
    transform: translate(-50%, 50%);
    width: 100%;
}

.ras-notice.is-preview {
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.6rem;
    border-top: 4px solid var(--ras-red);
    box-shadow: none;
}

.ras-notice-body {
    flex: 1 1 280px;
}

.ras-notice-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.ras-notice--required .ras-notice form,
.ras-notice--required form {
    margin-left: auto;
}

[data-theme="dark"] .ras-notice {
    background: #1c1f23;
    color: #e9ecef;
}

@media print {
    .ras-notice,
    .ras-notice-overlay {
        display: none !important;
    }
}

/* Cookie policy page and footer link. */
.policy-page {
    max-width: 820px;
}

.policy-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 1.75rem 0 0.6rem;
}

.policy-content h2:first-child {
    margin-top: 0;
}

.policy-content ul {
    padding-left: 1.25rem;
}

.policy-content li + li {
    margin-top: 0.35rem;
}

.footer-link {
    color: inherit;
    text-decoration: underline;
}

/* Header theme menu (signed-out visitors). The icon shows the current choice. */
.theme-menu-button {
    align-items: center;
    display: inline-flex;
    padding: 0.3rem 0.55rem;
}

.theme-icon {
    display: none;
}

[data-theme-choice="light"] .theme-icon-light,
[data-theme-choice="dark"] .theme-icon-dark,
[data-theme-choice="system"] .theme-icon-system,
:root:not([data-theme-choice]) .theme-icon-system {
    display: inline;
}

.top-header-actions .theme-menu {
    display: inline-flex;
}

/* Dashboard/landing copy that RAS Basic's dark stylesheet leaves dark gray. */
[data-theme="dark"] .dashboard-subtitle,
[data-theme="dark"] .dashboard-section-copy {
    color: #c4c9ce;
}

[data-theme="dark"] .dashboard-kicker {
    color: #ff8f99;
}

/* Admin > SMTP > Email template */
.template-colors {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.template-color {
    align-items: center;
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
}

.template-color .form-control-color {
    flex: 0 0 2.6rem;
    height: 2.2rem;
    padding: 0.15rem;
}

.template-preview {
    background: #f3f4f6;
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.5rem;
    height: 620px;
    width: 100%;
}

.template-logo {
    align-items: flex-start;
    border: 1px solid var(--ras-gray-border);
    border-radius: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem;
}

.template-logo-preview {
    align-items: center;
    border-radius: 0.4rem;
    display: flex;
    flex: 0 0 260px;
    justify-content: center;
    min-height: 90px;
    padding: 1rem;
}

.template-logo-preview img {
    height: auto;
    width: 100%;
}

/* Dashboard tiles: optional status-color accent and a period/filters hint. */
.stat-card.stat-accent {
    border-left: 4px solid var(--status-dot, #9aa5b1) !important;
}

.stat-hint {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    margin-top: -0.3rem;
}
