:root {
    --brand-green: #004d34;
    --brand-green-hover: #003826;
    --brand-green-light: #e6f4ea;
    --brand-purple: #9333ea;
    --bg-left: #004d34;
    --bg-right: #ffffff;
    --card-bg: #ffffff;
    --input-bg: #eef4ff;
    --input-border: #dce4f0;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --bubble-user: #d9fdd3;
    --bubble-user-text: #064e3b;
    --bubble-bot: #ffffff;
    --bubble-agent: #dcfce7;
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background: linear-gradient(90deg, var(--bg-left) 50%, var(--bg-right) 50%);
    color: var(--text-dark);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.chat-app-container {
    width: 100%;
    max-width: 960px;
    height: 92vh;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
.chat-header {
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--brand-green);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0, 77, 52, 0.2);
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

.brand-title {
    font-family: 'Outfit', sans-serif;
    line-height: 1.1;
}

.brand-title .logo-x {
    color: #c026d3;
    font-weight: 800;
    font-size: 20px;
}

.brand-title .logo-pert {
    color: var(--brand-green);
    font-weight: 800;
    font-size: 20px;
}

.brand-title .logo-sub {
    color: #334155;
    font-weight: 700;
    font-size: 20px;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--brand-green-light);
    border: 1px solid rgba(0, 77, 52, 0.15);
    font-size: 12px;
    color: var(--brand-green);
    font-weight: 600;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--brand-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--brand-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 77, 52, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(0, 77, 52, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 77, 52, 0);
    }
}

.icon-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--brand-green-light);
    color: var(--brand-green);
    border-color: rgba(0, 77, 52, 0.2);
}

/* Chat Body with Warm Beige Doodle Pattern Wallpaper */
.chat-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background-color: #efeae2;
    background-image: radial-gradient(rgba(0, 0, 0, 0.05) 1.2px, transparent 1.2px), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M39 16h2v6h-2zm0 8h2v6h-2zm-7-7h16v2H32zm45 20h2v6h-2zm0 8h2v6h-2zm-7-7h16v2H70zm-35 20h2v6h-2zm0 8h2v6h-2zm-7-7h16v2H32zm-32-20h2v6h-2zm0 8h2v6h-2zm-7-7h16v2H0z' fill='%23000000' fill-opacity='0.04'/%3E%3C/svg%3E");
    background-size: 32px 32px, 80px 80px;
    scroll-behavior: smooth;
    position: relative;
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Date Separator Pill */
.date-separator {
    display: flex;
    justify-content: center;
    margin: 10px 0;
    width: 100%;
    clear: both;
}

.date-pill {
    background: #ffffff;
    color: #556987;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.06);
    letter-spacing: 0.2px;
}

/* Floating Scroll Down Button */
.scroll-down-btn {
    position: absolute;
    right: 20px;
    bottom: 90px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    color: #475569;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    z-index: 25;
    transition: all 0.2s ease;
}

.scroll-down-btn:hover {
    background: #ffffff;
    color: var(--brand-green);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* History Loading Indicator */
.history-loader {
    display: none;
    text-align: center;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--brand-green);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    width: fit-content;
    margin: 0 auto 10px auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Message Bubbles */
.message-row {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out forwards;
}

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

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

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

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-size: cover;
    background-position: center;
}

.message-row.bot .avatar {
    background-color: var(--brand-green);
    color: #fff;
}

.message-row.agent .avatar {
    background-color: #059669;
    color: #fff;
}

.message-row.user .avatar {
    background-color: #ffffff;
    color: var(--brand-green);
    border: 1px solid #cbd5e1;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.55;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message-row.user .bubble {
    background: var(--bubble-user);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.message-row.bot .bubble {
    background: var(--bubble-bot);
    color: var(--text-dark);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom-left-radius: 4px;
}

.message-row.agent .bubble {
    background: var(--bubble-agent);
    color: #064e3b;
    border: 1px solid #86efac;
    border-bottom-left-radius: 4px;
}

.sender-tag {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.msg-time {
    font-size: 10px;
    opacity: 0.75;
    align-self: flex-end;
    margin-top: 4px;
}

/* Buttons / Chips */
.button-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chip-btn {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--brand-green);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip-btn:hover {
    background: var(--brand-green);
    color: #ffffff;
    border-color: var(--brand-green);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 77, 52, 0.2);
}

/* Footer Input Area */
.chat-footer {
    padding: 16px 24px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 12px;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 14px 20px;
    border-radius: 12px;
    color: var(--text-dark);
    font-size: 14.5px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: var(--brand-green);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 77, 52, 0.15);
}

.send-btn {
    background: var(--brand-green);
    border: none;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 77, 52, 0.2);
}

.send-btn:hover {
    background: var(--brand-green-hover);
    transform: scale(1.03);
}

/* Modal Guest Intake */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.intake-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 18px;
    padding: 36px 32px 24px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.intake-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.intake-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--brand-green);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(0, 77, 52, 0.3);
}

.intake-logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    line-height: 1;
    margin-bottom: 6px;
}

.intake-logo-text .logo-x {
    color: #c026d3;
    font-weight: 800;
}

.intake-logo-text .logo-pert {
    color: var(--brand-green);
    font-weight: 800;
}

.intake-logo-text .logo-erp {
    color: #334155;
    font-weight: 700;
}

.intake-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.styled-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.styled-input-group i {
    position: absolute;
    left: 14px;
    color: var(--text-light);
    font-size: 14px;
    pointer-events: none;
}

.form-input-theme {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 12px 14px 12px 38px;
    border-radius: 10px;
    color: var(--text-dark);
    font-size: 13.5px;
    outline: none;
    transition: all 0.2s ease;
}

.form-input-theme:focus {
    border-color: var(--brand-green);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 77, 52, 0.15);
}

.submit-btn-theme {
    background: var(--brand-green);
    color: #ffffff;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 77, 52, 0.25);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.submit-btn-theme:hover {
    background: var(--brand-green-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 77, 52, 0.3);
}

.theme-copyright {
    text-align: center;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    flex-direction: row !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: #ffffff;
    border-radius: 18px;
    width: fit-content;
    border: 1px solid var(--input-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin: 8px 0 12px 0;
}

.typing-indicator[style*="display: block"],
.typing-indicator[style*="display: inline-block"] {
    display: flex !important;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--brand-primary, #004d34);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 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;
}

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

@media (max-width: 768px) {
    html,
    body {
        height: 100%;
        height: 100dvh;
        overflow: hidden;
    }

    body {
        background: #efeae2;
        padding: 0;
    }

    .chat-app-container {
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .chat-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .header-brand {
        gap: 8px;
        min-width: 0;
        flex: 1;
    }

    .brand-avatar {
        width: 36px;
        height: 36px;
        font-size: 11px;
    }

    .brand-info {
        min-width: 0;
        overflow: hidden;
    }

    .brand-title img {
        width: 75px !important;
        height: auto;
    }

    .brand-subtitle {
        font-size: 10.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-actions {
        gap: 6px;
        flex-shrink: 0;
    }

    .status-badge {
        padding: 4px 8px;
        font-size: 11px;
        gap: 5px;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .chat-body {
        padding: 12px 10px;
        gap: 12px;
    }

    .message-row {
        max-width: 90%;
        gap: 8px;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .bubble {
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 14px;
    }

    .chat-footer {
        padding: 8px 10px;
        gap: 8px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .chat-input {
        padding: 10px 14px;
        font-size: 15px;
        border-radius: 10px;
    }

    .send-btn {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 15px;
    }

    .scroll-down-btn {
        right: 14px;
        bottom: 70px;
        width: 34px;
        height: 34px;
        font-size: 12px;
    }

    .modal-overlay {
        padding: 14px;
    }

    .intake-card {
        padding: 24px 18px 20px 18px;
        max-width: 100%;
        border-radius: 16px;
        gap: 14px;
    }
}

@media (max-width: 380px) {
    .brand-subtitle {
        display: none;
    }

    .status-badge span {
        display: none;
    }

    .status-badge {
        padding: 6px;
        border-radius: 50%;
    }
}
