/* chat-specific resets */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* Lock background scrolling */
    background: #f4f7f6;
    font-family: 'Inter', sans-serif;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height for mobile browsers */
    max-width: 600px;
    margin: 0 auto;
    background: var(--white);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* Progress */
.chat-progress-container {
    height: 3px;
    background: #e2e8f0;
    width: 100%;
}
.chat-progress-bar {
    height: 100%;
    background: var(--blue-600);
    width: 0%;
    transition: width 0.3s ease;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    z-index: 10;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--blue-900);
    margin-right: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}
.back-btn:hover { background: #f1f5f9; }
.back-btn svg { width: 24px; height: 24px; }

.agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.agent-avatar {
    position: relative;
    width: 40px;
    height: 40px;
}

.agent-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--white);
    border-radius: 50%;
}

.agent-details h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--blue-900);
}

.agent-details p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease forwards;
}

.message-wrapper.bot {
    align-self: flex-start;
}

.message-wrapper.user {
    align-self: flex-end;
}

.message {
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message-wrapper.bot .message {
    background: var(--white);
    color: var(--blue-900);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-wrapper.user .message {
    background: var(--blue-600);
    color: var(--white);
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: var(--white);
    border-top: 1px solid #e2e8f0;
    z-index: 10;
}

/* Options */
.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.option-btn {
    background: var(--white);
    border: 1px solid var(--blue-600);
    color: var(--blue-600);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.option-btn:hover, .option-btn:active {
    background: var(--blue-600);
    color: var(--white);
}

/* Text Input */
.text-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f1f5f9;
    padding: 4px 4px 4px 16px;
    border-radius: 24px;
}

.text-input-container input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 1rem;
    outline: none;
    font-family: inherit;
    color: var(--gray-900);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue-600);
    color: var(--white);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn svg {
    margin-left: -2px; /* slight visual offset for arrow */
}

/* Success Card */
.success-card {
    background: var(--white);
    border: 2px solid var(--green-500);
    padding: 24px;
    border-radius: var(--border-radius-lg);
    text-align: center;
    margin-top: 16px;
}

.success-card h3 {
    color: var(--green-500);
    margin-bottom: 8px;
    font-size: 1.25rem;
}

/* Error Messages */
.message.error-msg {
    color: #b91c1c; /* Dark red text */
    background: #fef2f2; /* Light red background */
    border: 1px solid #fecaca;
}

/* Undo Button */
.undo-btn {
    display: block;
    margin: 12px auto 0;
    background: transparent;
    border: none;
    color: var(--blue-500);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.undo-btn:hover {
    color: var(--blue-700);
}

.ref-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 12px;
    border-radius: var(--border-radius-md);
    margin: 16px 0;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blue-900);
    letter-spacing: 2px;
}
