/* RESET & BASE STYLES */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #FFFAFA;
    --text-color: #303235;
    --bot-bubble-bg: #FFFFFF;
    --bot-bubble-border: rgba(0, 0, 0, 0.06);
    --user-bubble-bg: #303235;
    --user-bubble-color: #FFFFFF;
    --accent-color: #25D366; /* Green for online status */
    --font-primary: 'Inter', sans-serif;
    --font-header: 'Outfit', sans-serif;
    --border-radius-large: 18px;
    --border-radius-small: 6px;
    --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-button: 0 4px 12px rgba(48, 50, 53, 0.12);
}

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    font-family: var(--font-primary);
    background-color: #f0f2f5;
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* CHATCONTAINER */
#chat-container {
    width: 100%;
    height: 100%;
    max-width: 640px;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

@media (min-width: 641px) {
    #chat-container {
        height: 92vh;
        border-radius: 20px;
        overflow: hidden;
        border: 1px solid rgba(0, 0, 0, 0.05);
    }
}

/* HEADER */
#chat-header {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px 20px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    position: relative;
    width: 42px;
    height: 42px;
}

#header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background-color: var(--accent-color);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: pulse-green 2s infinite;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

#header-title {
    font-family: var(--font-header);
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.01em;
}

#header-status {
    font-size: 0.75rem;
    font-weight: 500;
    color: #8c8c8c;
}

/* CHAT BODY */
#chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Hide scrollbar for Chrome, Safari and Opera */
#chat-body::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
#chat-body {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

#messages-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* BUBBLE CONTAINERS & LAYOUT */
.chat-bubble-container {
    display: flex;
    width: 100%;
    margin-bottom: 4px;
    opacity: 0;
    transform: translateY(12px);
    animation: bubble-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bubble-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message-container {
    justify-content: flex-start;
    align-items: flex-end;
    gap: 8px;
}

.user-message-container {
    justify-content: flex-end;
    align-items: flex-end;
}

.avatar-wrapper {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-bottom: 2px;
}

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

/* BUBBLE STYLES */
.chat-bubble {
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 80%;
    white-space: pre-wrap;
    word-break: break-word;
}

.bot-bubble {
    background-color: var(--bot-bubble-bg);
    color: var(--text-color);
    border-radius: var(--border-radius-large) var(--border-radius-large) var(--border-radius-large) var(--border-radius-small);
    border: 1px solid var(--bot-bubble-border);
    box-shadow: var(--shadow-subtle);
}

.user-bubble {
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    border-radius: var(--border-radius-large) var(--border-radius-large) var(--border-radius-small) var(--border-radius-large);
    box-shadow: var(--shadow-subtle);
}

.chat-bubble p {
    margin-bottom: 6px;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble strong {
    font-weight: 700;
}

.chat-bubble u {
    text-decoration: underline;
}

/* IMAGES & VIDEOS IN BUBBLES */
.media-content {
    margin-top: 6px;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.bubble-image {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
}

.bubble-image-standalone {
    max-width: 75%;
    max-height: 280px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: block;
    object-fit: contain;
    margin-bottom: 4px;
}

/* TYPING INDICATOR */
.typing-bubble {
    background-color: var(--bot-bubble-bg);
    border: 1px solid var(--bot-bubble-border);
    border-radius: var(--border-radius-large) var(--border-radius-large) var(--border-radius-large) var(--border-radius-small);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow-subtle);
}

.typing-bubble .dot {
    width: 7px;
    height: 7px;
    background-color: #8c96a0;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

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

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* FOOTER & INPUT OPTIONS */
#chat-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background-color: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
}

#input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    animation: footer-fade 0.25s ease-out;
}

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

/* CHOICE BUTTONS */
.choice-button {
    font-family: var(--font-primary);
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 8px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background-color 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: var(--shadow-button);
    display: flex;
    justify-content: center;
    align-items: center;
}

.choice-button:hover {
    background-color: #43464a;
}

.choice-button:active {
    transform: scale(0.985);
}

.choice-button:last-child {
    margin-bottom: 0;
}

/* NUMERIC/TEXT FORM */
.input-form {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-top: 4px;
}

.form-input {
    flex: 1;
    font-family: var(--font-primary);
    font-size: 16px;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background-color: #fff;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.15s ease-in-out;
}

.form-input:focus {
    border-color: var(--user-bubble-bg);
}

.form-submit-btn {
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 600;
    background-color: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    border: none;
    border-radius: 12px;
    padding: 14px 22px;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
    box-shadow: var(--shadow-button);
}

.form-submit-btn:hover {
    background-color: #43464a;
}

.form-submit-btn:active {
    transform: scale(0.98);
}

/* UTILITIES */
.hidden {
    display: none !important;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5); }
    70% { box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
