/* WP Podchat — isolated modern UI (colors/spacing controlled here, not theme) */
.interactive-podcast.wp-podchat,
.interactive-podcast {
    --ip-page: #e8ecf1;
    --ip-surface: #f1f4f8;
    --ip-elevated: #e2e8f0;
    --ip-border: #cbd5e1;
    --ip-border-strong: #94a3b8;
    --ip-input-border: #64748b;
    --ip-text: #0f172a;
    --ip-muted: #64748b;
    --ip-accent: #4f46e5;
    --ip-accent-hover: #4338ca;
    --ip-user-bg: #e0e7ff;
    --ip-user-border: #c7d2fe;
    --ip-assistant-bg: #f8fafc;
    --ip-assistant-border: #cbd5e1;
    --ip-input-bg: #ffffff;
    --ip-shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 4px 12px rgb(15 23 42 / 0.04);
    --ip-radius: 1rem;
    --ip-radius-sm: 0.75rem;

    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 1.5rem 0;
    padding: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.2rem;
    line-height: 1.55;
    color: var(--ip-text) !important;
    -webkit-text-fill-color: var(--ip-text) !important;
    box-sizing: border-box;
    clear: both;
    isolation: isolate;
    color-scheme: light;
    /* Outer shell: opaque so parent theme (e.g. red section bg) does not show through */
    background: var(--ip-page) !important;
    background-color: var(--ip-page) !important;
    background-image: none !important;
    position: relative;
    z-index: 1;
}

/* Beat common theme rules that set section/article backgrounds */
.entry-content .interactive-podcast,
.post-content .interactive-podcast,
article .interactive-podcast,
main .interactive-podcast,
.site-content .interactive-podcast,
.content-area .interactive-podcast,
.wp-block-group .interactive-podcast,
.widget .interactive-podcast {
    background: var(--ip-page) !important;
    background-color: var(--ip-page) !important;
    background-image: none !important;
}

.interactive-podcast *,
.interactive-podcast *::before,
.interactive-podcast *::after {
    box-sizing: border-box;
}

/* Block theme link/button colors inside the widget */
.interactive-podcast a {
    color: var(--ip-accent) !important;
    -webkit-text-fill-color: var(--ip-accent) !important;
}

.interactive-podcast a:hover {
    color: var(--ip-accent-hover) !important;
    -webkit-text-fill-color: var(--ip-accent-hover) !important;
}

.interactive-podcast__player {
    background: var(--ip-surface) !important;
    background-color: var(--ip-surface) !important;
    background-image: none !important;
    border: 1px solid var(--ip-border-strong) !important;
    border-radius: var(--ip-radius) var(--ip-radius) 0 0;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--ip-shadow);
}

.entry-content .interactive-podcast__player,
main .interactive-podcast__player,
article .interactive-podcast__player {
    background: var(--ip-surface) !important;
    background-color: var(--ip-surface) !important;
    background-image: none !important;
}

.interactive-podcast__audio {
    width: 100%;
    max-width: 100%;
    height: 48px;
    display: block;
    border-radius: var(--ip-radius-sm);
}

.interactive-podcast__chat {
    background: var(--ip-surface) !important;
    background-color: var(--ip-surface) !important;
    background-image: none !important;
    border: 1px solid var(--ip-border-strong) !important;
    border-radius: var(--ip-radius);
    padding: 1.35rem 1.5rem 1.5rem;
    box-shadow: var(--ip-shadow);
}

.entry-content .interactive-podcast__chat,
main .interactive-podcast__chat,
article .interactive-podcast__chat {
    background: var(--ip-surface) !important;
    background-color: var(--ip-surface) !important;
    background-image: none !important;
}

.interactive-podcast__player + .interactive-podcast__chat {
    border-top: none;
    border-radius: 0 0 var(--ip-radius) var(--ip-radius);
    box-shadow: var(--ip-shadow);
    margin-top: 0;
}

.interactive-podcast__player:only-of-type {
    border-radius: var(--ip-radius);
}

.interactive-podcast__heading {
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ip-muted) !important;
    -webkit-text-fill-color: var(--ip-muted) !important;
    margin: 0 0 1rem;
    padding: 0;
}

.interactive-podcast__warn {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e !important;
    -webkit-text-fill-color: #92400e !important;
    padding: 0.75rem 1rem;
    border-radius: var(--ip-radius-sm);
    font-size: 1rem;
    margin: 0 0 1rem;
    line-height: 1.45;
}

/* Chat shell: header + scrollable thread */
.interactive-podcast__messages {
    display: flex;
    flex-direction: column;
    min-height: 15rem;
    max-height: min(58vh, 36rem);
    border: 1px solid var(--ip-border-strong);
    border-radius: var(--ip-radius-sm);
    background: var(--ip-elevated) !important;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.45);
}

.interactive-podcast__thread-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
    padding: 0.85rem 1.1rem;
    background: linear-gradient(180deg, rgb(255 255 255 / 0.65) 0%, rgb(255 255 255 / 0.2) 100%);
    border-bottom: 1px solid var(--ip-border);
}

.interactive-podcast__thread-head-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    background: linear-gradient(145deg, var(--ip-accent) 0%, #6366f1 100%);
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    box-shadow: 0 2px 8px rgb(79 70 229 / 0.28);
}

.interactive-podcast__thread-head-icon svg {
    display: block;
}

.interactive-podcast__thread-head-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.interactive-podcast__thread-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ip-text) !important;
    -webkit-text-fill-color: var(--ip-text) !important;
    letter-spacing: -0.02em;
}

.interactive-podcast__thread-sub {
    font-size: 0.9rem;
    color: var(--ip-muted) !important;
    -webkit-text-fill-color: var(--ip-muted) !important;
    line-height: 1.35;
}

.interactive-podcast__thread {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem 0.85rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-color: var(--ip-border-strong) transparent;
}

.interactive-podcast__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem 0.85rem;
    align-items: end;
    margin-top: 1rem;
    width: 100%;
    min-width: 0;
}

@media (max-width: 36rem) {
    .interactive-podcast__form {
        grid-template-columns: 1fr;
    }
}

.interactive-podcast__input,
.interactive-podcast textarea.interactive-podcast__input {
    display: block;
    grid-column: 1;
    width: 100%;
    min-width: 0;
    min-height: 3.75rem;
    max-height: 12rem;
    padding: 1rem 1.15rem;
    border-radius: var(--ip-radius-sm);
    border: 2px solid var(--ip-input-border) !important;
    background: var(--ip-input-bg) !important;
    background-color: var(--ip-input-bg) !important;
    color: var(--ip-text) !important;
    -webkit-text-fill-color: var(--ip-text) !important;
    caret-color: var(--ip-accent) !important;
    font: inherit;
    font-size: 1.1875rem;
    line-height: 1.5;
    resize: vertical;
    opacity: 1 !important;
    box-shadow:
        inset 0 1px 2px rgb(15 23 42 / 0.05),
        0 1px 3px rgb(15 23 42 / 0.08) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.interactive-podcast__input::placeholder,
.interactive-podcast textarea.interactive-podcast__input::placeholder {
    color: var(--ip-muted) !important;
    -webkit-text-fill-color: var(--ip-muted) !important;
    opacity: 1 !important;
}

.interactive-podcast__input:focus,
.interactive-podcast textarea.interactive-podcast__input:focus {
    outline: none !important;
    border-color: var(--ip-accent) !important;
    box-shadow:
        inset 0 1px 2px rgb(15 23 42 / 0.05),
        0 0 0 3px rgb(79 70 229 / 0.25),
        0 2px 8px rgb(15 23 42 / 0.1) !important;
    color: var(--ip-text) !important;
    -webkit-text-fill-color: var(--ip-text) !important;
}

.interactive-podcast__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 1rem 1.85rem;
    min-height: 3.65rem;
    width: auto;
    max-width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    border: none;
    border-radius: var(--ip-radius-sm);
    background: var(--ip-accent) !important;
    background-image: none !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    font-weight: 600;
    font-size: 1.125rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    line-height: 1.25;
    white-space: nowrap;
    box-sizing: border-box;
    justify-self: end;
    grid-column: 2;
    grid-row: 1;
    box-shadow: 0 1px 2px rgb(79 70 229 / 0.25);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.interactive-podcast__send-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.interactive-podcast__send-icon svg {
    display: block;
}

.interactive-podcast__send-text {
    line-height: 1;
}

.interactive-podcast__send:hover:not(:disabled) {
    background: var(--ip-accent-hover) !important;
    filter: none;
    box-shadow: 0 2px 8px rgb(79 70 229 / 0.3);
}

.interactive-podcast__send:active:not(:disabled) {
    transform: translateY(1px);
}

@media (max-width: 36rem) {
    .interactive-podcast__send {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
        justify-self: stretch;
    }
}

.interactive-podcast__send:disabled,
.interactive-podcast__input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none !important;
}

/* Message rows: avatar + %-width bubble (chat-app layout) */
.interactive-podcast .ip-msg-row {
    display: flex;
    width: 100%;
    align-items: flex-end;
    gap: 0.75rem;
    min-width: 0;
}

.interactive-podcast .ip-msg-row--assistant {
    flex-direction: row;
    justify-content: flex-start;
}

.interactive-podcast .ip-msg-row--user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.interactive-podcast .ip-msg__avatar {
    flex-shrink: 0;
    width: 2.875rem;
    height: 2.875rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgb(15 23 42 / 0.12);
}

.interactive-podcast .ip-msg__avatar svg {
    width: 1.35rem;
    height: 1.35rem;
    display: block;
}

.interactive-podcast .ip-msg__avatar--user {
    background: linear-gradient(145deg, #6366f1 0%, var(--ip-accent) 100%);
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    border: 2px solid rgb(255 255 255 / 0.35);
}

.interactive-podcast .ip-msg__avatar--assistant {
    background: linear-gradient(145deg, #f8fafc 0%, var(--ip-elevated) 100%);
    color: var(--ip-accent) !important;
    -webkit-text-fill-color: var(--ip-accent) !important;
    border: 2px solid var(--ip-border-strong);
}

.interactive-podcast .ip-msg__col {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(88%, calc(100% - 3.5rem));
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.interactive-podcast .ip-msg__meta {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--ip-muted) !important;
    -webkit-text-fill-color: var(--ip-muted) !important;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 0.15rem;
}

.interactive-podcast .ip-msg-row--user .ip-msg__meta {
    text-align: right;
}

.interactive-podcast .ip-msg__bubble {
    padding: 1rem 1.2rem;
    font-size: 1.25rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ip-text) !important;
    -webkit-text-fill-color: var(--ip-text) !important;
    box-shadow: 0 2px 8px rgb(15 23 42 / 0.06);
}

.interactive-podcast .ip-msg__bubble--assistant {
    background: var(--ip-assistant-bg) !important;
    border: 1px solid var(--ip-assistant-border);
    border-radius: 1.25rem 1.25rem 1.25rem 0.35rem;
}

.interactive-podcast .ip-msg__bubble--user {
    background: var(--ip-user-bg) !important;
    border: 1px solid var(--ip-user-border);
    border-radius: 1.25rem 1.25rem 0.35rem 1.25rem;
    box-shadow: 0 2px 10px rgb(79 70 229 / 0.12);
}

.interactive-podcast .ip-msg__bubble--pending {
    opacity: 0.78;
}

.interactive-podcast .ip-msg__body {
    margin: 0;
    color: inherit !important;
    -webkit-text-fill-color: inherit !important;
}

.interactive-podcast-error {
    color: #b45309 !important;
    -webkit-text-fill-color: #b45309 !important;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--ip-radius-sm);
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
}

@media (max-width: 36rem) {
    .interactive-podcast .ip-msg__col {
        max-width: min(92%, calc(100% - 3.25rem));
    }

    .interactive-podcast .ip-msg__bubble {
        font-size: 1.125rem;
        padding: 0.9rem 1rem;
    }
}
