/* ── Chat App Layout ── */
.chat-app {
    max-width: 700px;
    margin: 0 auto;
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* ── Chat Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-white);
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.status-indicator {
    font-size: 0.8rem;
    color: #4caf50;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.status-indicator::before {
    content: "";
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* ── Message Bubbles ── */
.message {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    line-height: 1.5;
    font-size: 0.95rem;
    word-break: break-word;
    white-space: pre-wrap;
}

.user-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-bubble {
    background: var(--surface);
    color: var(--text);
    border-bottom-left-radius: 4px;
    white-space: normal;
}

/* 주문 카드가 포함된 봇 버블 - 카드가 비주얼 주체 */
.bot-bubble--card-container {
    background: transparent;
    padding: 0.25rem 0;
    box-shadow: none;
}

/* 간결 안내 버블 - 내용 적을 때 컴팩트 */
.bot-bubble--compact {
    padding: 0.5rem 0.75rem;
}

.bot-bubble--compact .guide-card__title {
    margin-bottom: 0.2rem;
}

.bot-bubble--compact .guide-card__list {
    margin-top: 0.15rem;
}

/* ── Typing Indicator ── */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 0.25rem 0;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ── Input Form ── */
.chat-input-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-input:focus {
    border-color: var(--primary);
}

.btn-send {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-send:hover {
    background: var(--primary-dark);
}

/* ── Image Upload Button ── */
.btn-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.btn-upload:hover {
    background: #f0f0f0;
    border-color: var(--primary);
}

/* ── Image Preview Bar ── */
.image-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid var(--border);
}

.image-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.preview-name {
    font-size: 0.85rem;
    color: var(--text-light);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-cancel-upload {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #999;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.btn-cancel-upload:hover {
    color: #c62828;
}

/* ── Chat Image Thumbnail ── */
.chat-upload-image {
    max-width: 260px;
    max-height: 195px;
    border-radius: 6px;
    display: block;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-upload-image:hover {
    opacity: 0.85;
}

.upload-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.25rem;
}

/* ── Analysis Result Card ── */
.analysis-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0;
}

.analysis-card h4 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.info-grid {
    display: grid;
    gap: 0.35rem;
}

.info-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem 0.75rem;
    font-size: 0.88rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid #d9d9d9;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item .label {
    font-weight: 600;
    min-width: 90px;
    color: #555;
    flex-shrink: 0;
}

.copyable-text {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 0.15rem;
    opacity: 0.4;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.copy-btn:hover {
    opacity: 1;
}

/* ── Address Validation Badge ── */
.address-validated {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #e8f5e9;
    border-radius: 6px;
    font-size: 0.88rem;
}

.validated-badge {
    background: #2e7d32;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.postal-code {
    color: #666;
    font-size: 0.85rem;
}

/* ── Image Lightbox Modal ── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    user-select: none;
}

.lightbox-toolbar {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
}

.lightbox-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.lightbox-btn.copied {
    background: #2e7d32;
}

/* .sr-only is defined in main.css */

/* ── Responsive ── */
@media (max-width: 768px) {
    .chat-app {
        border-left: none;
        border-right: none;
    }

    .chat-messages {
        padding: 0.75rem 1rem;
    }

    .message {
        max-width: 90%;
    }

    .image-preview {
        padding: 0.5rem 1rem;
    }

    .chat-upload-image {
        max-width: 195px;
        max-height: 156px;
    }

    .lightbox-btn-text {
        display: none;
    }

    .lightbox-btn {
        padding: 0.6rem;
    }
}
