/**
 * flugbuchen.de — Reiseberater (AI Chat) Styles
 *
 * Full-page AI travel advisor chat interface.
 * Mobile-first, responsive, a11y-ready.
 *
 * @copyright reDim GmbH | @link https://www.redim.de | @contact team@redim.de
 */

/* ========================================
   Page Header
   ======================================== */

.rb-header {
    padding: 1.5rem 0 1rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.rb-header__title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.rb-header__subtitle {
    font-size: 1rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

@media (min-width: 768px) {
    .rb-header {
        padding: 2rem 0 1.25rem;
    }

    .rb-header__title {
        font-size: 2rem;
    }

    .rb-header__subtitle {
        font-size: 1.0625rem;
    }
}

/* ========================================
   Breadcrumb
   ======================================== */

.rb-breadcrumb {
    margin-bottom: 0.75rem;
}

.rb-breadcrumb__list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

.rb-breadcrumb__item + .rb-breadcrumb__item::before {
    content: "\203A";
    margin-right: 0.5rem;
    color: var(--color-text-secondary);
}

.rb-breadcrumb__item a {
    color: var(--color-text-secondary);
    text-decoration: none;
}

.rb-breadcrumb__item a:hover {
    color: var(--color-secondary);
}

.rb-breadcrumb__item--current {
    color: var(--color-primary);
    font-weight: 600;
}

/* ========================================
   Chat Section Layout
   ======================================== */

.rb-chat-section {
    padding: 0;
    background: var(--color-bg-alt);
}

.rb-chat-layout {
    display: flex;
    min-height: calc(100vh - 4rem - 6rem - 3.5rem);
    gap: 0;
    position: relative;
}

@media (min-width: 768px) {
    .rb-chat-layout {
        min-height: calc(100vh - 4rem - 7rem - 3.5rem);
    }
}

/* ========================================
   Sidebar
   ======================================== */

.rb-sidebar {
    display: none;
    width: 100%;
    position: fixed;
    top: 4rem;
    left: 0;
    bottom: 0;
    z-index: 50;
    background: var(--color-bg);
    overflow-y: auto;
    border-right: 1px solid var(--color-border);
}

.rb-sidebar.is-open {
    display: block;
}

@media (min-width: 1024px) {
    .rb-sidebar {
        display: block;
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        width: 280px;
        min-width: 280px;
        z-index: auto;
        border-right: 1px solid var(--color-border);
        background: var(--color-bg);
    }

    .rb-sidebar.is-open {
        display: block;
    }
}

.rb-sidebar__inner {
    padding: 1.5rem 1.25rem;
}

.rb-sidebar__heading {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.rb-sidebar__topics {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.rb-sidebar__topic-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    min-height: 2.75rem;
}

.rb-sidebar__topic-btn:hover {
    background: var(--color-bg-alt);
    border-color: var(--color-border);
}

.rb-sidebar__topic-btn:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.rb-sidebar__icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: var(--color-secondary);
}

.rb-sidebar__info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--color-bg-alt);
    border-radius: var(--radius-sm);
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.rb-sidebar__info-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: var(--color-secondary);
    margin-top: 0.125rem;
}

.rb-sidebar__info p {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* ========================================
   Sidebar Toggle (Mobile)
   ======================================== */

.rb-sidebar-toggle {
    position: fixed;
    bottom: 5rem;
    left: 1rem;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    min-height: 2.75rem;
    min-width: 2.75rem;
}

.rb-sidebar-toggle__icon {
    width: 1rem;
    height: 1rem;
}

@media (min-width: 1024px) {
    .rb-sidebar-toggle {
        display: none;
    }
}

/* ========================================
   Chat Widget (Main Area)
   ======================================== */

.rb-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    min-width: 0;
}

@media (min-width: 1024px) {
    .rb-chat {
        border-left: none;
    }
}

/* ========================================
   Messages Container
   ======================================== */

.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    .chat-widget__messages {
        padding: 2rem 2rem;
    }
}

@media (min-width: 1024px) {
    .chat-widget__messages {
        padding: 2rem 3rem;
    }
}

/* ========================================
   Chat Messages
   ======================================== */

.chat-message {
    max-width: 80%;
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@media (min-width: 768px) {
    .chat-message {
        max-width: 70%;
    }
}

/* AI messages — left */
.chat-message--ai {
    align-self: flex-start;
    background: var(--color-bg-alt);
    color: var(--color-text);
    border-bottom-left-radius: 0.25rem;
}

/* User messages — right */
.chat-message--user {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

/* Error messages */
.chat-message--error {
    align-self: flex-start;
    background: #FEF2F2;
    color: var(--color-error);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-bottom-left-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Typing indicator */
.chat-message--typing {
    align-self: flex-start;
    background: var(--color-bg-alt);
    color: transparent;
    border-bottom-left-radius: 0.25rem;
    position: relative;
    min-width: 4.5rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.875rem 1.25rem;
}

.chat-message--typing::before,
.chat-message--typing::after,
.chat-message--typing span {
    content: "";
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--color-text-secondary);
    opacity: 0.4;
    animation: rb-typing 1.4s infinite ease-in-out;
}

.chat-message--typing::before {
    animation-delay: 0s;
}

.chat-message--typing::after {
    animation-delay: 0.2s;
}

/* The textContent from JS creates a text node, visually hidden via color: transparent.
   The dots are CSS pseudo-elements. We add a third dot via box-shadow on ::after. */

/* Simplified: use only ::before and ::after for 3 dots */
.chat-message--typing {
    font-size: 0;
}

.chat-message--typing::before {
    animation-delay: 0s;
}

.chat-message--typing::after {
    animation-delay: 0.4s;
    box-shadow: -0.875rem 0 0 -0.0625rem var(--color-text-secondary);
    animation: rb-typing-last 1.4s infinite ease-in-out;
}

@keyframes rb-typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-0.25rem);
    }
}

@keyframes rb-typing-last {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
        box-shadow: -0.875rem 0 0 -0.0625rem var(--color-text-secondary);
    }
    30% {
        opacity: 1;
        transform: translateY(-0.25rem);
        box-shadow: -0.875rem 0 0 -0.0625rem var(--color-text-secondary);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-message--typing::before,
    .chat-message--typing::after {
        animation: none;
        opacity: 0.5;
    }
}

/* Markdown in AI messages */
.chat-message--ai ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.chat-message--ai li {
    margin-bottom: 0.25rem;
}

.chat-message--ai strong {
    font-weight: 700;
}

.chat-message--ai em {
    font-style: italic;
}

/* ========================================
   Suggestion Pills
   ======================================== */

.chat-widget__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.chat-widget__suggestion {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-secondary);
    background: transparent;
    border: 1.5px solid var(--color-secondary);
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: 2.75rem;
    text-align: left;
    line-height: 1.4;
}

.chat-widget__suggestion:hover {
    background: var(--color-secondary);
    color: #fff;
}

.chat-widget__suggestion:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* ========================================
   Input Area
   ======================================== */

.rb-chat__input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

@media (min-width: 768px) {
    .rb-chat__input-area {
        padding: 1rem 2rem;
    }
}

@media (min-width: 1024px) {
    .rb-chat__input-area {
        padding: 1rem 3rem;
    }
}

.rb-chat__input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--color-bg-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    transition: border-color 0.2s ease;
}

.rb-chat__input-wrap:focus-within {
    border-color: var(--color-secondary);
}

.chat-widget__input-field {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--color-text);
    line-height: 1.5;
    padding: 0.375rem 0;
    resize: none;
    min-height: 1.5rem;
    max-height: 7.5rem;
    outline: none;
}

.chat-widget__input-field::placeholder {
    color: var(--color-text-secondary);
}

.chat-widget__input-field:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-widget__send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    background: var(--color-secondary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.chat-widget__send-btn:hover {
    background: var(--color-secondary-hover);
}

.chat-widget__send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-widget__send-btn:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.chat-widget__send-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Max messages hint */
.chat-widget__max-hint {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    text-align: center;
}

.chat-widget__max-hint.is-visible {
    display: block;
}

/* ========================================
   Trust Bar
   ======================================== */

.rb-trust {
    padding: 1.5rem 0;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.rb-trust__list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem 2.5rem;
    list-style: none;
}

.rb-trust__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.rb-trust__icon {
    width: 1.125rem;
    height: 1.125rem;
    color: var(--color-secondary);
    flex-shrink: 0;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 767px) {
    .rb-chat-layout {
        flex-direction: column;
    }

    .chat-message {
        max-width: 90%;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .rb-sidebar-toggle {
        bottom: 5.5rem;
    }
}

/* ========================================
   Chat Wrapper
   ======================================== */

.rb-chat-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    min-width: 0;
}

/* ========================================
   Dark Mode Toggle
   ======================================== */

.rb-darkmode-toggle {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    color: var(--color-text-secondary);
}

.rb-darkmode-toggle:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.rb-darkmode-toggle:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.rb-darkmode-toggle svg {
    width: 1.125rem;
    height: 1.125rem;
}

.rb-darkmode-toggle__sun {
    display: none;
}

.rb-darkmode-toggle__moon {
    display: block;
}

/* ========================================
   Dark Mode Styles
   ======================================== */

.rb-chat-section.dark-mode {
    --dm-bg: #0F172A;
    --dm-bg-chat: #1E293B;
    --dm-bg-message: #334155;
    --dm-text: #F1F5F9;
    --dm-text-secondary: #94A3B8;
    --dm-border: #334155;
    --dm-user-msg: #0D9488;
    background: var(--dm-bg);
}

.rb-chat-section.dark-mode .rb-sidebar {
    background: var(--dm-bg);
    border-right-color: var(--dm-border);
}

.rb-chat-section.dark-mode .rb-sidebar__heading {
    color: var(--dm-text);
}

.rb-chat-section.dark-mode .rb-sidebar__topic-btn {
    color: var(--dm-text);
}

.rb-chat-section.dark-mode .rb-sidebar__topic-btn:hover {
    background: var(--dm-bg-chat);
    border-color: var(--dm-border);
}

.rb-chat-section.dark-mode .rb-sidebar__info {
    background: var(--dm-bg-chat);
}

.rb-chat-section.dark-mode .rb-sidebar__info p {
    color: var(--dm-text-secondary);
}

.rb-chat-section.dark-mode .rb-chat {
    background: var(--dm-bg-chat);
}

.rb-chat-section.dark-mode .chat-message--ai {
    background: var(--dm-bg-message);
    color: var(--dm-text);
}

.rb-chat-section.dark-mode .chat-message--user {
    background: var(--dm-user-msg);
    color: #fff;
}

.rb-chat-section.dark-mode .chat-message--error {
    background: rgba(220, 38, 38, 0.15);
    color: #FCA5A5;
    border-color: rgba(220, 38, 38, 0.3);
}

.rb-chat-section.dark-mode .chat-message--typing {
    background: var(--dm-bg-message);
}

.rb-chat-section.dark-mode .chat-message--typing::before,
.rb-chat-section.dark-mode .chat-message--typing::after {
    background: var(--dm-text-secondary);
}

.rb-chat-section.dark-mode .chat-widget__suggestion {
    color: var(--dm-text);
    border-color: var(--dm-text-secondary);
}

.rb-chat-section.dark-mode .chat-widget__suggestion:hover {
    background: var(--dm-user-msg);
    border-color: var(--dm-user-msg);
    color: #fff;
}

.rb-chat-section.dark-mode .rb-chat__input-area {
    background: var(--dm-bg);
    border-top-color: var(--dm-border);
}

.rb-chat-section.dark-mode .rb-chat__input-wrap {
    background: var(--dm-bg-message);
    border-color: var(--dm-border);
}

.rb-chat-section.dark-mode .chat-widget__input-field {
    color: var(--dm-text);
}

.rb-chat-section.dark-mode .chat-widget__input-field::placeholder {
    color: var(--dm-text-secondary);
}

.rb-chat-section.dark-mode .chat-widget__max-hint {
    color: var(--dm-text-secondary);
}

.rb-chat-section.dark-mode .rb-darkmode-toggle {
    background: var(--dm-bg-message);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

.rb-chat-section.dark-mode .rb-darkmode-toggle:hover {
    background: var(--dm-border);
}

.rb-chat-section.dark-mode .rb-darkmode-toggle__sun {
    display: block;
}

.rb-chat-section.dark-mode .rb-darkmode-toggle__moon {
    display: none;
}

.rb-chat-section.dark-mode .rb-sidebar-toggle {
    background: var(--dm-bg-message);
}
