/* ===================================================================
   TLC Voice Agent widget — TLC-VA-001
   Brand tokens are inherited from styles.css (--accent, --brand-*).
   Fallback values are inlined so the widget still renders correctly if
   it is ever loaded on a page that does not ship the main stylesheet.
   =================================================================== */

.tlc-va {
    --va-accent: var(--accent, #5A8A2E);
    --va-accent-bright: var(--accent-bright, #8BC34A);
    --va-brand-light: var(--brand-light, #DCFEC5);
    --va-ink: var(--gray-700, #2A2A2A);
    --va-muted: var(--gray-400, #6b786b);
    --va-line: var(--gray-100, #e0e5e0);
    --va-urgent: #C62828;
    --va-font: var(--font-main, 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif);
}

/* ---------- Launcher ----------
   Sits above the existing text-chat FAB (bottom:28px) rather than on top
   of it. Keep the two offsets in sync if either launcher moves. */
.tlc-va-fab {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2A2A2A 0%, #3D5E1F 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(42, 42, 42, 0.4);
    z-index: 9997;
    font-family: var(--va-font);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.tlc-va-fab:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(42, 42, 42, 0.5); }
.tlc-va-fab:focus-visible { outline: 3px solid var(--va-brand-light); outline-offset: 3px; }
.tlc-va-fab .tlc-va-ico-close { display: none; }
.tlc-va-fab.is-open .tlc-va-ico-mic { display: none; }
.tlc-va-fab.is-open .tlc-va-ico-close { display: block; }

/* Live-call ring */
.tlc-va-fab.is-live { background: linear-gradient(135deg, var(--va-accent) 0%, var(--va-accent-bright) 100%); }
.tlc-va-fab.is-live::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--va-accent-bright);
    animation: tlc-va-ring 1.6s ease-out infinite;
}

@keyframes tlc-va-ring {
    0%   { transform: scale(0.95); opacity: 0.9; }
    100% { transform: scale(1.25); opacity: 0; }
}

/* Silent nudge label (§3) — never plays audio */
.tlc-va-nudge {
    position: fixed;
    bottom: 118px;
    right: 104px;
    max-width: 230px;
    background: #fff;
    color: var(--va-ink);
    font-family: var(--va-font);
    font-size: 0.85rem;
    line-height: 1.4;
    padding: 10px 14px;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
    z-index: 9997;
    cursor: pointer;
    border: 1px solid var(--va-line);
}

.tlc-va-nudge button {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--va-line);
    background: #fff;
    color: var(--va-muted);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
}

/* ---------- Panel ---------- */
.tlc-va-panel {
    position: fixed;
    bottom: 180px;
    right: 28px;
    width: 372px;
    max-width: calc(100vw - 32px);
    max-height: min(620px, calc(100vh - 210px));
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.24);
    z-index: 9997;
    font-family: var(--va-font);
    color: var(--va-ink);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--va-line);
}

.tlc-va-panel[hidden] { display: none !important; }

.tlc-va-head {
    background: linear-gradient(135deg, #2A2A2A 0%, #3D5E1F 100%);
    color: #fff;
    padding: 16px 18px;
    flex-shrink: 0;
}

.tlc-va-head h3 { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: 0.01em; }
.tlc-va-head p  { margin: 3px 0 0; font-size: 0.78rem; opacity: 0.85; line-height: 1.4; }

.tlc-va-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Recording + privacy notice — displayed, never spoken (§3) */
.tlc-va-notice {
    background: var(--va-brand-light);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.76rem;
    line-height: 1.45;
    color: #33461f;
}

.tlc-va-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--va-muted);
}

.tlc-va-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--va-muted);
    flex-shrink: 0;
}

.tlc-va-status.is-live { color: var(--va-accent); }
.tlc-va-status.is-live::before { background: var(--va-accent-bright); animation: tlc-va-blink 1.4s ease-in-out infinite; }
.tlc-va-status.is-error { color: var(--va-urgent); }
.tlc-va-status.is-error::before { background: var(--va-urgent); }

@keyframes tlc-va-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Visualiser */
.tlc-va-viz {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 46px;
}

.tlc-va-viz span {
    width: 4px;
    height: 8px;
    border-radius: 2px;
    background: var(--va-line);
    transition: height 0.12s ease, background-color 0.2s ease;
}

.tlc-va-viz.is-live span { background: var(--va-accent-bright); }

.tlc-va-transcript {
    background: #F7FBF3;
    border: 1px solid var(--va-line);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 0.86rem;
    line-height: 1.5;
    min-height: 68px;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.tlc-va-transcript b { color: var(--va-accent); font-weight: 800; }

.tlc-va-error {
    background: #FDECEA;
    color: #A31515;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.79rem;
    line-height: 1.45;
}

.tlc-va-error[hidden] { display: none !important; }

/* Buttons */
.tlc-va-btn {
    width: 100%;
    padding: 13px 18px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-family: var(--va-font);
    font-size: 0.94rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition: filter 0.2s ease, transform 0.15s ease;
}

.tlc-va-btn:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.tlc-va-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.tlc-va-btn-start { background: linear-gradient(135deg, var(--va-accent) 0%, var(--va-accent-bright) 100%); color: #fff; }
.tlc-va-btn-end   { background: var(--va-urgent); color: #fff; }

.tlc-va-btn-ghost {
    background: transparent;
    color: var(--va-accent);
    border: 1.5px solid var(--va-line);
    font-size: 0.83rem;
    padding: 10px 14px;
}

/* Typed-details panel — §5 requires email to be typed, not voice-captured */
.tlc-va-details { border-top: 1px solid var(--va-line); padding-top: 12px; }

.tlc-va-details > summary {
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 800;
    color: var(--va-accent);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tlc-va-details > summary::-webkit-details-marker { display: none; }
.tlc-va-details > summary::before { content: '\002B'; font-weight: 800; }
.tlc-va-details[open] > summary::before { content: '\2212'; }

.tlc-va-details .tlc-va-hint { font-size: 0.75rem; color: var(--va-muted); margin: 8px 0 10px; line-height: 1.45; }

.tlc-va-details label {
    display: block;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--va-muted);
    margin-bottom: 3px;
}

.tlc-va-details input,
.tlc-va-details textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1.5px solid var(--va-line);
    border-radius: 9px;
    font-family: var(--va-font);
    font-size: 0.86rem;
    margin-bottom: 9px;
    color: var(--va-ink);
    background: #fff;
}

.tlc-va-details input:focus,
.tlc-va-details textarea:focus { outline: none; border-color: var(--va-accent-bright); }
.tlc-va-details textarea { resize: vertical; min-height: 62px; }

.tlc-va-photos { font-size: 0.75rem; color: var(--va-muted); margin-bottom: 9px; }
.tlc-va-photos ul { margin: 6px 0 0; padding-left: 16px; }

.tlc-va-ok {
    background: var(--va-brand-light);
    color: #33461f;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 0.79rem;
    line-height: 1.45;
    font-weight: 700;
}

.tlc-va-ok[hidden] { display: none !important; }
.tlc-va-foot { font-size: 0.7rem; color: var(--va-muted); text-align: center; line-height: 1.45; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .tlc-va-fab { bottom: 156px; right: 20px; width: 58px; height: 58px; }
    .tlc-va-nudge { bottom: 168px; right: 88px; max-width: 180px; }

    .tlc-va-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 88vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tlc-va-fab,
    .tlc-va-fab::after,
    .tlc-va-status::before,
    .tlc-va-viz span { animation: none !important; transition: none !important; }
}
