/* ═══════════════════════════════════════════════════════════════
   AI Career Coach widget — light-mode + structural rules.

   Dark-mode rules live in `resources/css/dark-mode.css` (scoped under
   `.dark`). Per CLAUDE.md both `resources/css/coach.css` and
   `public/assets/css/coach.css` are kept hand-synced — do NOT refactor
   one through Vite without mirroring the other.

   Layout:
     - Floating launcher button in the bottom inline-end corner.
     - On open, a panel slides up. ≤ 420 px on desktop.
     - At ≤ 900 px and ≤ 768 px the panel becomes a bottom sheet.

   RTL/LTR is handled with logical CSS (inset-inline-end) so the same
   ruleset works in both directions.
   ═══════════════════════════════════════════════════════════════ */

.coach-widget {
    position: fixed;
    inset-block-end: 24px;
    inset-inline-end: 24px;
    z-index: 1000;
    font-family: inherit;
}

.coach-widget__launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--hp-gold, #D4AF37);
    color: var(--hp-navy, #1A1A2E);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 120ms ease;
}

.coach-widget__launcher:hover {
    transform: scale(1.05);
}

.coach-widget__panel {
    position: fixed;
    inset-block-end: 96px;
    inset-inline-end: 24px;
    width: min(420px, calc(100vw - 48px));
    max-height: min(640px, calc(100vh - 120px));
    background: var(--hp-surface, #FFFFFF);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.coach-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-block-end: 1px solid rgba(0, 0, 0, 0.06);
    background: var(--hp-cream, #FAF8F4);
}

.coach-widget__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: var(--hp-navy, #1A1A2E);
}

.coach-widget__close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--hp-navy, #1A1A2E);
}

.coach-widget__body {
    display: grid;
    grid-template-columns: minmax(140px, 32%) 1fr;
    gap: 0;
    flex: 1 1 auto;
    min-height: 0;
}

.coach-widget__conversations {
    border-inline-end: 1px solid rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

.coach-widget__chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.coach-widget__welcome {
    padding: 16px;
    font-size: 14px;
    color: var(--hp-navy, #1A1A2E);
    opacity: 0.8;
}

.coach-widget__messages {
    list-style: none;
    padding: 12px;
    margin: 0;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.coach-widget__composer {
    border-block-start: 1px solid rgba(0, 0, 0, 0.06);
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.coach-widget__composer-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.coach-widget__composer-input {
    flex: 1 1 100%;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 8px 10px;
    font: inherit;
    resize: vertical;
    min-height: 44px;
}

.coach-widget__composer-send {
    margin-inline-start: auto;
    background: var(--hp-gold, #D4AF37);
    color: var(--hp-navy, #1A1A2E);
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-weight: 700;
    cursor: pointer;
}

.coach-widget__composer-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.coach-widget__error {
    grid-column: 1 / -1;
    padding: 10px 14px;
    background: rgba(220, 53, 69, 0.08);
    color: #b02a37;
    border-block-end: 1px solid rgba(220, 53, 69, 0.16);
    font-size: 14px;
}

/* ─── Conversation list ──────────────────────────────────────── */

.coach-conversations__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-block-end: 8px;
}

.coach-conversations__new,
.coach-conversations__wipe {
    flex: 1 1 auto;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: transparent;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
}

.coach-conversations__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.coach-conversations__item {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 6px;
}

.coach-conversations__item.is-active {
    background: rgba(212, 175, 55, 0.12);
}

.coach-conversations__select {
    flex: 1 1 auto;
    text-align: start;
    border: none;
    background: transparent;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.coach-conversations__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hp-navy, #1A1A2E);
}

.coach-conversations__meta {
    font-size: 11px;
    opacity: 0.65;
}

.coach-conversations__delete {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    opacity: 0.5;
}

.coach-conversations__delete:hover {
    opacity: 1;
}

.coach-conversations__empty {
    padding: 8px;
    font-size: 12px;
    opacity: 0.65;
    margin: 0;
}

/* ─── Message bubble ─────────────────────────────────────────── */

.coach-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.coach-bubble--user {
    align-self: flex-end;
    background: var(--hp-gold-light, #D4AF37);
    color: var(--hp-navy, #1A1A2E);
}

.coach-bubble--assistant {
    align-self: flex-start;
    background: var(--hp-cream, #FAF8F4);
    color: var(--hp-navy, #1A1A2E);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.coach-bubble__content {
    white-space: pre-wrap;
}

.coach-bubble__rating {
    margin-block-start: 4px;
    display: flex;
    gap: 4px;
}

.coach-bubble__rate {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    padding: 2px 4px;
}

.coach-bubble__rate.is-active,
.coach-bubble__rate:hover {
    opacity: 1;
}

/* ─── Upsell card ────────────────────────────────────────────── */

.coach-upsell {
    grid-column: 1 / -1;
    padding: 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.coach-upsell__headline {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--hp-navy, #1A1A2E);
}

.coach-upsell__body {
    margin: 0;
    font-size: 14px;
    opacity: 0.85;
}

.coach-upsell__cta {
    display: inline-block;
    align-self: center;
    background: var(--hp-gold, #D4AF37);
    color: var(--hp-navy, #1A1A2E);
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
}

/* ─── Responsive — tablet (≤ 900px) ──────────────────────────── */

@media (max-width: 900px) {
    .coach-widget__panel {
        width: min(420px, calc(100vw - 32px));
        max-height: calc(100vh - 120px);
    }
    .coach-widget__body {
        grid-template-columns: minmax(120px, 35%) 1fr;
    }
}

/* ─── Responsive — mobile (≤ 768px) — bottom sheet ───────────── */

@media (max-width: 768px) {
    .coach-widget__panel {
        inset-inline: 0;
        inset-block-end: 0;
        width: 100vw;
        max-width: 100vw;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        border-inline-start: none;
        border-inline-end: none;
        border-block-end: none;
    }
    .coach-widget__body {
        grid-template-columns: 1fr;
    }
    .coach-widget__conversations {
        max-height: 28vh;
        border-inline-end: none;
        border-block-end: 1px solid rgba(0, 0, 0, 0.06);
    }
}
