/*
 * Shared UI components ported from RAS Basic (public/css/components.css):
 * area headers, status badges, account settings (tabs, toggles, chips,
 * password fields, appearance choices), the header theme menu and the live
 * password checklist.
 */

:root {
    --ras-focus-color: var(--ras-red);
}

[data-theme="dark"] {
    --ras-focus-color: #ff6b75;
}

/* 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;
}

/* ---------------------------------------------------------------------------
 * 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);
    /* Transparent outline becomes visible in forced-colors mode, where box-shadow is removed. */
    outline: 2px solid transparent;
}

/* Selection is shown by a check mark too, not only by the ring colour. */
.color-choice input:checked + .status-badge::after {
    content: "\2713";
    margin-left: 0.25rem;
}

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

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

/* ---------------------------------------------------------------------------
 * 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-focus-color);
    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-focus-color);
    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; hide the outline only when the browser
   would not show a keyboard focus indicator anyway. */
[role="tabpanel"]:focus:not(:focus-visible) {
    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;
    }
}

.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 (.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-focus-color);
    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;
}


/* 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;
}

/* Live password checklist (<x-form.password-requirements>). */
.password-requirements li {
    align-items: baseline;
    display: flex;
    gap: 0.4rem;
}

.password-requirement-icon::before {
    content: "\25CB"; /* ○ */
    display: inline-block;
    text-align: center;
    width: 1em;
}

.password-requirements li.is-met {
    color: var(--bs-success-text-emphasis, #0f5132);
}

.password-requirements li.is-met .password-requirement-icon::before {
    content: "\2713"; /* ✓ */
    font-weight: 700;
}

[data-theme="dark"] .password-requirements li.is-met {
    color: #75b798;
}

/* 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%;
}


/* WYSIWYG Markdown editor (components/markdown-editor, Toast UI Editor). */
.markdown-editor.is-invalid .toastui-editor-defaultUI {
    border-color: var(--bs-form-invalid-border-color);
}

.markdown-editor .toastui-editor-contents {
    font-family: inherit;
    font-size: 1rem;
}

.markdown-editor .toastui-editor-defaultUI-toolbar button {
    border-radius: 0.35rem;
}

/* ---------------------------------------------------------------------------
 * 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-primary: var(--ras-red);
    --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);
}

.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);
}
