/* 
  Chat Interface Styles
  Matches the Next Level Summit premium dark theme
*/

:root {
    --chat-bg: var(--primary-dark);
    --chat-header-bg: rgba(10, 25, 47, 0.95);
    --bot-bubble-bg: var(--secondary-dark);
    --bot-bubble-text: var(--text-white);
    --user-bubble-bg: var(--gradient-orange);
    --user-bubble-text: var(--text-white);
    --input-bg: var(--secondary-dark);
    --input-border: rgba(0, 180, 216, 0.3);
}

body.chat-page {
    margin: 0;
    padding: 0;
    background-color: var(--chat-bg);
    height: 100vh;
    height: 100dvh; /* For mobile dynamic viewport */
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    color: var(--text-white);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--primary-dark); /* Fallback */
    background-image: 
        radial-gradient(circle at top right, rgba(255, 107, 0, 0.03), transparent 40%),
        radial-gradient(circle at bottom left, rgba(0, 119, 255, 0.03), transparent 40%);
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    position: relative;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--chat-header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
    position: sticky;
    top: 0;
}

.back-btn {
    color: var(--text-white);
    font-size: 1.5rem;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s;
    text-decoration: none;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

.agent-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.agent-avatar img {
    width: 80%;
    height: auto;
    border-radius: 50%;
    object-fit: contain;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--chat-header-bg);
}

.status-indicator.online {
    background-color: #04d361;
}

.agent-details {
    display: flex;
    flex-direction: column;
}

.agent-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 2px 0;
    color: var(--text-white);
}

.agent-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.header-actions {
    display: flex;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-white);
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
}

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

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

.user-row {
    align-self: flex-end;
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message-bubble p {
    margin: 0;
}

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

.bot-bubble {
    background-color: var(--bot-bubble-bg);
    color: var(--bot-bubble-text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.user-bubble {
    background: var(--user-bubble-bg);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(255, 107, 0, 0.2);
}

.message-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
    padding: 0 4px;
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    animation: slideUp 0.4s ease forwards;
    animation-delay: 0.8s;
    opacity: 0;
}

.quick-reply-btn {
    background: rgba(255, 107, 0, 0.1);
    color: var(--accent-orange);
    border: 1px solid rgba(255, 107, 0, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: var(--accent-orange);
    color: #fff;
}

/* Input Area */
.chat-input-area {
    background: var(--chat-bg);
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    padding: 4px 8px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: rgba(255, 107, 0, 0.5);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-white);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 10px 12px;
    resize: none;
    max-height: 120px;
    outline: none;
    line-height: 1.4;
}

.message-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.send-btn {
    background: var(--accent-orange);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 4px;
    transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
}

.send-btn i {
    font-size: 1.2rem;
    margin-left: 2px; /* optical alignment */
}

.send-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    transform: scale(0.9);
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    background: #ff5500;
}

.chat-footer-branding {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 8px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

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

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

/* Initial Messages Staggered Animation */
.initial-msg:nth-child(1) { animation-delay: 0.1s; opacity: 0; animation-fill-mode: forwards; }
.initial-msg:nth-child(2) { animation-delay: 0.4s; opacity: 0; animation-fill-mode: forwards; }
.initial-msg:nth-child(3) { animation-delay: 0.7s; opacity: 0; animation-fill-mode: forwards; }

/* Markdown Formatting in chat (basic) */
.message-bubble a {
    color: var(--accent-orange);
    text-decoration: underline;
}
.message-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

/* Big Structured Checkout Button */
.checkout-btn-container {
    display: flex;
    justify-content: center;
    margin: 16px 0; /* More breathing room top and bottom */
    width: 100%;
}

.checkout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-orange);
    color: #ffffff !important;
    padding: 12px 28px;
    border-radius: 100px; /* Perfect pill shape */
    font-weight: 600; /* Slightly less heavy than 700 or 800 */
    text-decoration: none !important;
    font-size: 0.95rem; /* Better scale inside a chat bubble */
    box-shadow: 0 8px 24px rgba(255, 107, 0, 0.25);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    max-width: 95%;
}

.checkout-btn i {
    margin-right: 8px;
    font-size: 1.05rem;
}

.checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(255, 107, 0, 0.35);
}

.checkout-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.2);
}

/* --- Mobile Responsiveness --- */
@media screen and (max-width: 480px) {
    .checkout-btn-container {
        margin: 12px 0;
    }

    .checkout-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        max-width: 100%;
        border-radius: 24px; /* More forgiving for multi-line text */
        line-height: 1.3;
        white-space: normal;
    }

    .checkout-btn i {
        font-size: 1rem;
        margin-right: 6px;
    }
}
