:root {
    --bg: #f4efe8;
    --text: #2f2e2c;
    --accent: #8c7156;
    --border: #d6c4a2;
    --white: #ffffff;
    --chatbot-bg: #ffffff;
    --bot-msg-bg: #f0f0f0;
    --user-msg-bg: #8c7156;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Inter", sans-serif;
    background: var(--bg);
    min-height: 100vh;
    padding: 20px;
}

/* Nút Back về trang chủ */
.back-home {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.back-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--white);
    color: var(--accent);
    text-decoration: none;
    border-radius: 8px;
    border: 2px solid var(--accent);
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.back-btn:hover {
    background: var(--accent);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tv-container {
    max-width: 900px;
    margin: 60px auto 20px;
    background: var(--white);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Chatbot Container */
.chatbot-container {
    width: 100%;
}

.chatbot-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--chatbot-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-info h3 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
}

.chatbot-status {
    font-size: 12px;
    color: #4caf50;
}

.chatbot-messages {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 12px;
}

.bot-message {
    background: var(--bot-msg-bg);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    max-width: 80%;
    animation: slideIn 0.3s ease;
}

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

/* Step Container */
.step-container {
    margin-top: 20px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.option-btn {
    padding: 14px 20px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
    transition: all 0.3s ease;
    font-weight: 500;
}

.option-btn:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(140, 113, 86, 0.3);
}

.option-btn:active {
    transform: translateY(0);
}

/* Image Scroll Container */
.image-scroll-container {
    margin-top: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.image-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.image-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.image-scroll-container::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.image-scroll-list {
    display: flex;
    gap: 15px;
    padding: 10px;
    min-width: min-content;
}

.image-item {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.image-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(140, 113, 86, 0.3);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Room Choice Buttons */
.room-choice-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.choice-btn {
    flex: 1;
    min-width: 200px;
    padding: 16px 24px;
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.choice-btn:hover {
    background: #7a6049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(140, 113, 86, 0.3);
}

/* Upload Container */
.upload-container {
    margin-top: 20px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: rgba(140, 113, 86, 0.05);
}

.upload-label {
    display: block;
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
}

.upload-label small {
    display: block;
    margin-top: 8px;
    color: #888;
    font-weight: normal;
}

.preview-image {
    margin-top: 20px;
    text-align: center;
}

.preview-image img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, #7a6049 100%);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(140, 113, 86, 0.3);
    margin-top: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(140, 113, 86, 0.4);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Progress Container */
.progress-container {
    margin-top: 20px;
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #7a6049 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
}

/* Result Container */
.result-container {
    text-align: center;
    padding: 20px;
}

.result-container h2 {
    font-family: "Playfair Display", serif;
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--accent);
}

.result-image-box {
    margin: 20px 0;
}

.result-image-box img {
    max-width: 100%;
    max-height: 600px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

.download-btn, .reset-btn {
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.download-btn {
    background: var(--accent);
    color: var(--white);
}

.download-btn:hover {
    background: #7a6049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(140, 113, 86, 0.3);
}

.reset-btn {
    background: var(--white);
    color: var(--accent);
    border: 2px solid var(--accent);
}

.reset-btn:hover {
    background: var(--accent);
    color: var(--white);
    transform: translateY(-2px);
}

.status-message {
    margin-top: 20px;
    font-size: 15px;
    color: var(--text);
}

/* Responsive */
@media (max-width: 768px) {
    .back-home {
        position: relative;
        top: 0;
        left: 0;
        margin-bottom: 15px;
    }

    .tv-container {
        margin-top: 20px;
        padding: 20px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .image-item {
        width: 150px;
        height: 150px;
    }

    .room-choice-buttons {
        flex-direction: column;
    }

    .choice-btn {
        width: 100%;
    }
}

/* Popup Rate Limit */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.popup-content {
    background: var(--white);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.popup-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--accent);
    font-weight: 700;
}

.popup-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.popup-close:hover {
    background: #f0f0f0;
    color: var(--text);
}

.popup-body {
    padding: 24px;
}

.popup-body p {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
}

.popup-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.popup-btn-ok {
    padding: 12px 28px;
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.popup-btn-ok:hover {
    background: #7a6049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(140, 113, 86, 0.3);
}

.popup-btn-ok:active {
    transform: translateY(0);
}

/* Responsive popup */
@media (max-width: 768px) {
    .popup-content {
        width: 95%;
        margin: 20px;
    }

    .popup-header {
        padding: 16px 20px;
    }

    .popup-header h3 {
        font-size: 18px;
    }

    .popup-body {
        padding: 20px;
    }

    .popup-footer {
        padding: 12px 20px 20px;
    }
}
