/* ── Gripe Intake Chat Widget ─────────────────────────────────────── */

.gripe-intake-widget {
    display: flex;
    flex-direction: column;
    height: 580px;
    max-width: 700px;
    margin: 0 auto;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background: #ffffff;
    color: #111827;
}

/* ── Message area ─────────────────────────────────────────────────── */

.gripe-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

.gripe-chat-messages::-webkit-scrollbar { width: 5px; }
.gripe-chat-messages::-webkit-scrollbar-track { background: transparent; }
.gripe-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ── Message rows ─────────────────────────────────────────────────── */

.gripe-message {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    animation: gripe-fadein .18s ease;
}

@keyframes gripe-fadein {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gripe-bot-message  { align-self: flex-start; align-items: flex-start; }
.gripe-user-message { align-self: flex-end;   align-items: flex-end;   }

/* ── Bubbles ──────────────────────────────────────────────────────── */

.gripe-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-break: break-word;
    white-space: pre-wrap;
}

.gripe-bot-message .gripe-bubble {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.gripe-user-message .gripe-bubble {
    background: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* label inside bot bubble */
.gripe-bubble strong {
    display: block;
    margin-bottom: 2px;
}

.gripe-required { color: #ef4444; }

.gripe-hint {
    display: block;
    font-size: .82em;
    color: #9ca3af;
    margin-top: 2px;
}

/* ── Select option buttons ────────────────────────────────────────── */

.gripe-options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-left: 2px;
}

.gripe-opt-btn {
    padding: 6px 15px;
    border: 1.5px solid #2563eb;
    border-radius: 20px;
    background: #ffffff;
    color: #2563eb;
    font-size: .88em;
    cursor: pointer;
    transition: background .14s, color .14s;
    font-family: inherit;
}

.gripe-opt-btn:hover:not(:disabled)  { background: #eff6ff; }
.gripe-opt-btn:disabled              { cursor: default; opacity: .55; }
.gripe-opt-btn.gripe-opt-selected    { background: #2563eb; color: #ffffff; }

/* ── Checkbox Yes/No buttons ──────────────────────────────────────── */

.gripe-yesno-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ── Skip link ────────────────────────────────────────────────────── */

.gripe-skip-row  { margin-top: 5px; }

.gripe-skip-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: .82em;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    font-family: inherit;
}

.gripe-skip-btn:hover { color: #6b7280; }

/* ── Typing indicator ─────────────────────────────────────────────── */

.gripe-typing .gripe-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    min-width: 52px;
}

.gripe-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    display: inline-block;
    animation: gripe-bounce .9s infinite;
}

.gripe-dot:nth-child(2) { animation-delay: .15s; }
.gripe-dot:nth-child(3) { animation-delay: .30s; }

@keyframes gripe-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-5px); }
}

/* ── Summary ──────────────────────────────────────────────────────── */

.gripe-summary-list {
    list-style: none;
    margin: 8px 0 12px;
    padding: 0;
}

.gripe-summary-list li {
    padding: 5px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: .9em;
}

.gripe-summary-list li:last-child { border-bottom: none; }

.gripe-summary-label {
    font-weight: 600;
    margin-right: 5px;
}

/* ── Summary action row ───────────────────────────────────────────── */

.gripe-action-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.gripe-confirm-btn {
    padding: 9px 22px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: .95em;
    font-weight: 600;
    cursor: pointer;
    transition: background .14s;
    font-family: inherit;
}

.gripe-confirm-btn:hover:not(:disabled)  { background: #1d4ed8; }
.gripe-confirm-btn:disabled              { opacity: .65; cursor: not-allowed; }

.gripe-restart-btn {
    padding: 9px 16px;
    background: none;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: .95em;
    color: #6b7280;
    cursor: pointer;
    transition: border-color .14s, color .14s;
    font-family: inherit;
}

.gripe-restart-btn:hover:not(:disabled)  { border-color: #9ca3af; color: #374151; }
.gripe-restart-btn:disabled              { opacity: .65; cursor: not-allowed; }

/* ── Success state ────────────────────────────────────────────────── */

.gripe-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 32px 24px;
    animation: gripe-fadein .3s ease;
}

.gripe-success-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #d1fae5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    color: #059669;
}

.gripe-success p {
    font-size: 1.05em;
    max-width: 340px;
    color: #374151;
    line-height: 1.65;
    margin: 0;
}

/* ── Input area ───────────────────────────────────────────────────── */

.gripe-chat-input-area {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.gripe-progress {
    height: 3px;
    background: #e5e7eb;
}

.gripe-progress-bar {
    height: 3px;
    background: #2563eb;
    width: 0%;
    transition: width .3s ease;
}

.gripe-input-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 10px;
}

.gripe-text-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: .95em;
    font-family: inherit;
    outline: none;
    background: #f9fafb;
    color: #111827;
    transition: border-color .15s, background .15s;
    min-width: 0;
}

.gripe-text-input:focus  { border-color: #2563eb; background: #ffffff; }
.gripe-text-input:disabled { opacity: .45; cursor: not-allowed; }

.gripe-text-input.gripe-input-shake {
    border-color: #ef4444;
    animation: gripe-shake .3s;
}

@keyframes gripe-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60%  { transform: translateX(-4px); }
    40%, 80%  { transform: translateX(4px); }
}

.gripe-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .14s;
    padding: 0;
}

.gripe-send-btn:hover:not(:disabled)  { background: #1d4ed8; }
.gripe-send-btn:disabled              { opacity: .45; cursor: not-allowed; }

/* ── Config error ─────────────────────────────────────────────────── */

.gripe-config-error {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #b91c1c;
    font-size: .9em;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 520px) {
    .gripe-intake-widget {
        height: 500px;
        border-radius: 12px;
    }

    .gripe-chat-messages { padding: 16px 12px 12px; }
    .gripe-message       { max-width: 90%; }
    .gripe-input-row     { padding: 10px 10px; }
}
