/* Container */
.hibww-chat-container {
    max-width: 450px;
    margin: 30px auto;
    border-radius: var(--hibww-border-radius, 20px);
    font-family: var(--hibww-font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    background: var(--hibww-bg, #ffffff);
    backdrop-filter: var(--hibww-backdrop, none);
    -webkit-backdrop-filter: var(--hibww-backdrop, none);
    box-shadow: var(--hibww-box-shadow, 0 10px 40px rgba(0, 0, 0, 0.08));
    display: flex;
    flex-direction: column;
    height: 600px;
    overflow: hidden;
    color: var(--hibww-text-color, #111);
}

/* Header */
.hibww-chat-header {
    background: var(--hibww-header-bg, #ffffff);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(128, 128, 128, 0.15);
}

.hibww-chat-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--hibww-header-text, #111);
    font-weight: 600;
    letter-spacing: -0.3px;
}

.hibww-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hibww-restart-btn, .hibww-close-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    padding: 0;
}

.hibww-restart-btn:hover, .hibww-close-btn:hover {
    color: var(--hibww-header-text, #111);
}

/* Messages area */
.hibww-chat-messages {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Bubbles */
.hibww-message {
    display: flex;
    max-width: 85%;
    animation: airwFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

.hibww-bot {
    align-self: flex-start;
    flex-direction: row;
    max-width: 95%;
    gap: 10px;
}

.hibww-bot-content {
	display: flex;
	flex-direction: column;
}

.hibww-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	align-self: flex-end;
}

.hibww-user {
    align-self: flex-end;
    flex-direction: column;
}

.hibww-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Bot minimalist bubble */
.hibww-bot .hibww-bubble {
    background: #9c205e;
    color: #ffffff;
    border: none;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* User minimalist bubble */
.hibww-user .hibww-bubble {
    background: #1b7187;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Lenker inni meldinger */
.hibww-bubble a {
    color: #ffffff !important;
    text-decoration: underline !important;
    font-weight: 500;
}
.hibww-bubble a:hover {
    color: #e0f0ff !important;
}
.hibww-user .hibww-bubble a {
    color: #8ab4f8 !important;
}
.hibww-user .hibww-bubble a:hover {
    color: #aecbfa !important;
}

.hibww-bubble strong {
    font-weight: 600;
}

/* Options */
.hibww-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.hibww-option-btn {
    background: transparent;
    border: 1px solid currentColor;
    color: var(--hibww-text-color, #333);
    padding: 10px 16px;
    border-radius: 100px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.hibww-option-btn:hover:not(:disabled) {
    background: var(--hibww-text-color, #111);
    color: var(--hibww-bg, #fff);
    border-color: var(--hibww-text-color, #111);
}

.hibww-option-btn:disabled {
    opacity: 0.4 !important;
    cursor: default;
}

/* Sources */
.hibww-sources {
    margin-top: 12px;
    font-size: 12px;
    border-top: 1px solid #eaeaea;
    padding-top: 10px;
}
.hibww-sources ul { margin: 6px 0 0 16px; padding: 0; }
.hibww-sources a { color: #555; text-decoration: none; border-bottom: 1px solid #ccc; transition: color 0.2s; }
.hibww-sources a:hover { color: #111; border-color: #111; }

/* Input area */
.hibww-chat-input-area {
    display: flex;
    padding: 16px 24px;
    background: transparent;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    gap: 12px;
    align-items: center;
}

.hibww-chat-input-area input {
    flex-grow: 1;
    padding: 14px 20px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 100px;
    font-size: 16px; /* Viktig: Må være minst 16px for å unngå auto-zoom på iOS/iPhone */
    outline: none;
    background: var(--hibww-input-bg, rgba(128, 128, 128, 0.05));
    color: var(--hibww-text-color, #111);
    transition: background 0.2s, border-color 0.2s;
}

.hibww-chat-input-area input:focus {
    background: var(--hibww-input-bg, rgba(128, 128, 128, 0.1));
    border-color: var(--hibww-text-color, rgba(128, 128, 128, 0.4));
}

.hibww-chat-input-area input::placeholder {
    color: var(--hibww-text-color, #111);
    opacity: 0.6;
}

.hibww-chat-input-area button {
    background: var(--hibww-text-color, #111);
    color: var(--hibww-bg, white);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}

.hibww-chat-input-area button:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.hibww-chat-input-area button svg {
    margin-left: -2px; /* optical centering */
}

/* Loader */
.hibww-loading-indicator {
    display: flex;
    gap: 6px;
    padding: 4px 24px 16px 24px;
    background: transparent;
}
.hibww-dot {
    width: 6px;
    height: 6px;
    background-color: #bbb;
    border-radius: 50%;
    animation: airwBlink 1.4s infinite both;
}
.hibww-dot:nth-child(1) { animation-delay: 0s; }
.hibww-dot:nth-child(2) { animation-delay: 0.2s; }
.hibww-dot:nth-child(3) { animation-delay: 0.4s; }

/* Animations */
@keyframes airwBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

@keyframes airwFadeUp {
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .hibww-chat-container {
        border-radius: 20px;
        height: 80vh;
        max-height: 80vh;
        margin: 5vh auto;
    }
}

/* Floating Mode Styles */
.hibww-floating-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 2147483647;
    font-family: var(--hibww-font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.hibww-floating-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 10px 10px;
    border-radius: 50px; /* Keep pill shape */
    background: var(--hibww-bg, rgba(255, 255, 255, 0.7));
    backdrop-filter: var(--hibww-backdrop, blur(16px));
    -webkit-backdrop-filter: var(--hibww-backdrop, blur(16px));
    border: 1px solid rgba(128, 128, 128, 0.2);
    box-shadow: var(--hibww-box-shadow, 0 8px 32px rgba(0, 0, 0, 0.1));
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--hibww-text-color, #111);
    overflow: hidden;
    white-space: nowrap;
    max-width: 300px; /* Safe upper limit */
}

.hibww-floating-bubble.hibww-collapsed {
    padding: 10px; /* Circle padding */
    gap: 0;
    max-width: 66px; /* Just enough for img 44px + pad 20px + border 2px */
}

.hibww-floating-bubble:hover {
    box-shadow: var(--hibww-box-shadow, 0 12px 40px rgba(0, 0, 0, 0.15));
    transform: scale(1.02);
}

.hibww-floating-bubble.hibww-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.hibww-floating-bubble img.hibww-bubble-avatar {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

.hibww-bubble-text {
    font-weight: 600;
    font-size: 15px;
    opacity: 1;
    transition: opacity 0.3s ease, max-width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.hibww-floating-bubble.hibww-collapsed .hibww-bubble-text {
    opacity: 0;
    width: 0;
}

.hibww-floating-chat-container {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 40px);
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.hibww-floating-chat-container.hibww-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.hibww-floating-chat-container .hibww-chat-container {
    margin: 0;
    height: 600px;
    max-height: calc(100vh - 100px);
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
}

.hibww-floating-wrapper.hibww-left {
    right: auto;
    left: 30px;
}

.hibww-floating-wrapper.hibww-left .hibww-floating-chat-container {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

@media (max-width: 600px) {
    .hibww-floating-wrapper {
        bottom: 20px;
        right: 20px;
    }
    .hibww-floating-wrapper.hibww-left {
        right: auto;
        left: 20px;
    }
    .hibww-floating-chat-container {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 100%;
        z-index: 2147483647;
    }
    .hibww-floating-chat-container .hibww-chat-container {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }
    .hibww-floating-chat-container .hibww-chat-header {
        padding-top: max(20px, env(safe-area-inset-top));
    }
}
