/* Brand Colors - Navy and Yellow */
:root {
    --navy: #142e4a;
    --yellow: #eac14c;
    --white: #ffffff;
    --light-gray: #f5f5f5;
    --border-gray: #e0e0e0;
    --text-dark: #333333;
    --text-light: #666666;
    --shadow: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
}

/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: inherit;
}

/* Widget Toggle Button */
.widget-toggle {
    height: 60px;
    padding: 0 24px;
    border-radius: 30px;
    background: var(--yellow);
    color: var(--navy);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
}

.widget-toggle-text {
    white-space: nowrap;
}

.widget-toggle:hover {
    background: #d4ab3a;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(234, 193, 76, 0.3);
}

.widget-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px var(--shadow);
}

.widget-toggle svg {
    width: 28px;
    height: 28px;
}

/* Chat Container */
.chat-container {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chat-widget.active .chat-container {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.chat-widget.active .widget-toggle {
    opacity: 0;
    pointer-events: none;
}

/* Header */
.chat-header {
    background: var(--navy);
    color: var(--white);
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-text h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: var(--white);
}

.header-subtitle {
    font-size: 11px;
    margin: 2px 0 0 0;
    color: var(--white);
    opacity: 0.9;
    font-weight: 400;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--white);
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.close-btn:hover {
    background: rgba(20, 46, 74, 0.1);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--white);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-gray);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.welcome-message {
    text-align: left;
    color: var(--text-dark);
}

.welcome-message p {
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Selection Boxes */
.selection-boxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.selection-box {
    background: var(--white);
    border: 2px solid var(--navy);
    color: var(--navy);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
}

.selection-box:hover {
    background: var(--navy);
    color: var(--white);
    transform: translateX(4px);
}

.selection-box:active {
    transform: translateX(2px);
}

/* Flow Buttons (from button flows) - Reverted to original in-bubble styling */
.flow-button-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    max-width: 100%;
}

.flow-button {
    background: var(--white);
    border: 2px solid var(--navy);
    color: var(--navy);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
}

.flow-button:hover {
    background: var(--navy);
    color: var(--white);
    transform: translateX(4px);
}

.flow-button:active {
    transform: translateX(2px);
}

.flow-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Message Styles */
.message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease-in;
    align-items: flex-start;
}

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

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

.message.bot {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: contain;
    background: var(--navy);
    padding: 4px;
}

.message.user .message-avatar {
    display: none;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.message.user .message-content {
    background: var(--navy);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: var(--light-gray);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
}

/* Selection boxes in messages */
.message-content .selection-boxes {
    margin-top: 8px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: var(--light-gray);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 70px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border-gray);
    background: var(--white);
}

.chat-form {
    display: flex;
    gap: 8px;
}

.message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-gray);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: var(--navy);
}

.send-btn {
    background: var(--yellow);
    color: var(--navy);
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-weight: 600;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: #d4a83a;
    transform: translateY(-1px);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Contact Modal */
.contact-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.contact-modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow);
}

.modal-content h3 {
    color: var(--navy);
    margin-bottom: 8px;
    font-size: 20px;
}

.modal-subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--navy);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-cancel,
.btn-submit {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-cancel {
    background: var(--light-gray);
    color: var(--text-dark);
}

.btn-cancel:hover {
    background: var(--border-gray);
}

.btn-submit {
    background: var(--navy);
    color: var(--white);
}

.btn-submit:hover {
    background: #0f1f33;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 76px;
        right: 0;
        border-radius: 16px 16px 0 0;
    }

    .widget-toggle {
        width: 60px;
        height: 60px;
        padding: 0;
        border-radius: 50%;
        gap: 0;
    }

    .widget-toggle-text {
        display: none;
    }

    .widget-toggle svg {
        width: 26px;
        height: 26px;
    }

    .chat-nudge {
        right: 72px;
        max-width: calc(100vw - 100px);
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

.chat-nudge {
    position: absolute;
    right: 70px;
    bottom: 10px;
    background: rgba(255,255,255,0.95);
    color: var(--text-dark);
    padding: 8px 12px;
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    font-size: 12px;
    max-width: 160px;
    border: 1px solid var(--border-gray);
    cursor: pointer;
}
.chat-widget.active .chat-nudge {
    display: none;
}

/* ── Embed mode ─────────────────────────────────────────────────────────
   Inside the embeddable iframe the viewport is narrow (<=480px), which
   would trigger the mobile circle-only launcher. Keep the full
   "How can I help you?" pill in embed mode. Higher specificity than the
   media query, so it wins regardless of source order. */
body.embed-mode .widget-toggle {
    width: auto;
    height: 60px;
    padding: 0 24px;
    border-radius: 30px;
    gap: 12px;
}
body.embed-mode .widget-toggle-text {
    display: inline;
}

/* Embed mode: when the chat is open, let the panel fill the iframe so there
   is no transparent gap below the input bar (the launcher's reserved space).
   Higher specificity than the base + mobile rules, so it wins. */
body.embed-mode .chat-widget.active .chat-container {
    position: fixed;
    /* Inset by the device safe areas (notch / Dynamic Island / home indicator)
       so the navy header and its close button are never clipped on phones. */
    top: calc(12px + env(safe-area-inset-top, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    height: auto;
    max-height: none;
}
