:root {
    --chat-bg-color: #f9fafb;
    --chat-header-bg: #ffffff;
    --chat-header-text: #111827;
    --chat-primary-button: #0f4c75;
    --chat-primary-button-text: #ffffff;
    --chat-primary-button-hover: #0a3a5c;
    --chat-user-bubble: #0f4c75;
    --chat-user-bubble-text: #ffffff;
    --chat-agent-bubble: #e5e7eb;
    --chat-agent-bubble-text: #111827;
    --chat-input-border: #d1d5db;
    --chat-input-focus-border: #0f4c75;
    --chat-input-bg: #ffffff;
    --chat-input-text: #111827;
    --chat-bubble-radius: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--chat-bg-color);
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 600px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--chat-primary-button);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chat-header {
    background: var(--chat-header-bg);
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-logo {
    min-width: 40px;
    max-width: 120px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f4c75;
    color: white;
    border-radius: 8px;
    font-weight: bold;
    font-size: 20px;
}

.chat-logo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.chat-header-title {
    color: var(--chat-header-text);
    font-size: 18px;
    font-weight: 600;
}

.chat-custom-header, .chat-custom-footer {
    padding: 12px 20px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.chat-custom-footer {
    border-bottom: none;
    border-top: 1px solid #e5e7eb;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-bg-color);
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 16px;
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--chat-bubble-radius);
    word-wrap: break-word;
    line-height: 1.5;
    white-space: pre-wrap;
    position: relative;
}

.message.user .message-bubble {
    background: var(--chat-user-bubble);
    color: var(--chat-user-bubble-text);
}

.message.assistant .message-bubble {
    background: var(--chat-agent-bubble);
    color: var(--chat-agent-bubble-text);
}

/* Streaming text with fade-in effect */
.message-bubble.streaming {
    animation: fadeIn 0.2s ease-in;
}

/* ChatGPT-style fade-in for new text */
.stream-text {
    display: inline;
}

.stream-chunk {
    display: inline;
    animation: textFadeIn 0.2s ease-out;
}

@keyframes textFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Blinking cursor removed */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: var(--chat-agent-bubble);
    border-radius: var(--chat-bubble-radius);
    width: fit-content;
}

.typing-indicator.show {
    display: inline-block;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #6b7280;
    border-radius: 50%;
    margin: 0 2px;
    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);
    }
    30% {
        transform: translateY(-10px);
    }
}

.chat-input-container {
    padding: 24px;
    background: var(--chat-bg-color);
}

.chat-input-form {
    position: relative;
}

.input-wrapper {
    position: relative;
}

.chat-input {
    width: 100%;
    min-height: 48px;
    max-height: 200px;
    padding: 14px 52px 14px 20px;
    border: 2px solid var(--chat-input-border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    background: var(--chat-input-bg);
    color: var(--chat-input-text);
    resize: none;
    overflow-y: auto;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-input:focus {
    border-color: var(--chat-input-focus-border);
    box-shadow: 0 4px 12px rgba(15, 76, 117, 0.15);
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input::-webkit-scrollbar {
    width: 6px;
}

.chat-input::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
    margin: 4px;
}

.chat-input::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-input::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.send-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 32px;
    height: 32px;
    background: #9ca3af;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-button:not(:disabled),
.send-button.active {
    background: var(--chat-primary-button);
    color: var(--chat-primary-button-text);
}
.send-button:not(:disabled):hover,
.send-button.active:hover {
    background: var(--chat-primary-button-hover);
}
.send-button svg {
    stroke: currentColor;
}

.send-button.active:hover {
    background: #1e5a8a;
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        height: -webkit-fill-available;
        max-height: 100vh;
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .chat-input-container {
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .message-bubble {
        max-width: 85%;
    }

    .chat-input {
        max-height: 160px;
        min-height: 44px;
        padding: 12px 48px 12px 16px;
        border-radius: 10px;
    }

    .send-button {
        width: 30px;
        height: 30px;
        right: 10px;
        bottom: 11px;
        border-radius: 5px;
    }
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 20px;
}

.modal-body {
    color: #4b5563;
    line-height: 1.6;
}

.welcome-text {
    margin-bottom: 16px;
    color: #374151;
    line-height: 1.6;
}

.welcome-text:last-of-type {
    margin-bottom: 24px;
}

.disclaimer-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
    cursor: pointer;
}

.disclaimer-item.single-check {
    margin-top: 8px;
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
}

.disclaimer-item:hover {
    background-color: #f3f4f6;
}

.disclaimer-item.single-check:hover {
    background-color: #f3f4f6;
    border-color: var(--chat-primary-button);
}

.disclaimer-checkbox {
    position: relative;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.disclaimer-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.disclaimer-checkmark {
    position: absolute;
    inset: 0;
    background-color: #ffffff;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.disclaimer-item:hover .disclaimer-checkmark {
    border-color: var(--chat-primary-button);
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.disclaimer-checkbox input:checked ~ .disclaimer-checkmark {
    background-color: var(--chat-primary-button);
    border-color: var(--chat-primary-button);
}

.disclaimer-checkmark::after {
    content: "";
    position: absolute;
    display: none;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    top: 1px;
    left: 5px;
}

.disclaimer-checkbox input:checked ~ .disclaimer-checkmark::after {
    display: block;
}

.disclaimer-text {
    color: #374151;
    font-size: 14px;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
}

.disclaimer-text a {
    color: var(--chat-primary-button);
    text-decoration: none;
    font-weight: 500;
}

.disclaimer-text a:hover {
    text-decoration: underline;
}

.terms-statement {
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    margin: 8px 0;
    text-align: center;
    color: #374151;
    font-size: 14px;
    line-height: 1.6;
}

.terms-statement a {
    color: var(--chat-primary-button);
    text-decoration: none;
    font-weight: 500;
}

.terms-statement a:hover {
    text-decoration: underline;
}

.modal-button-single {
    width: 100%;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: #d1d5db;
    color: #9ca3af;
}

.modal-button-single.enabled {
    background: var(--chat-primary-button);
    color: var(--chat-primary-button-text);
}

.modal-button-single.enabled:hover {
    background: var(--chat-primary-button-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 76, 117, 0.3);
}

/* ============================================================================
   INTAKE FORM STYLES
   ============================================================================ */

.form-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px;
    background: var(--chat-bg-color);
    scroll-behavior: smooth;
}

.form-intro {
    max-width: 500px;
    margin: 0 auto 32px;
    text-align: center;
}

.form-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--chat-header-text);
    margin-bottom: 12px;
}

.form-description {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.5;
}

.intake-form {
    max-width: 500px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

/* Form Sections */
.form-section {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid #e5e7eb;
}

.form-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.form-section-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--chat-header-text);
    margin-bottom: 24px;
}

/* Checkbox Styles */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: #f9fafb;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--chat-primary-button);
}

.checkbox-text {
    font-size: 15px;
    color: #374151;
    font-weight: 500;
}

/* Form Rows for Multi-Column Layouts */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group-half {
    flex: 1;
    margin-bottom: 0;
}

.form-group-quarter {
    flex: 0 0 calc(25% - 12px);
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.required {
    color: #dc2626;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--chat-input-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--chat-input-text);
    background: var(--chat-input-bg);
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--chat-input-focus-border);
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.form-input.error {
    border-color: #dc2626;
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.form-error {
    display: none;
    color: #dc2626;
    font-size: 13px;
    margin-top: 6px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-actions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.form-submit-button {
    width: 100%;
    padding: 14px 24px;
    background: var(--chat-primary-button);
    color: var(--chat-primary-button-text);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-submit-button:hover:not(:disabled) {
    background: var(--chat-primary-button-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 76, 117, 0.3);
}

.form-submit-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Success Message */
.form-success {
    max-width: 500px;
    margin: 60px auto;
    text-align: center;
    padding: 40px 20px;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dcfce7;
    border-radius: 50%;
    color: #16a34a;
}

.success-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--chat-header-text);
    margin-bottom: 16px;
}

.success-message {
    font-size: 16px;
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 12px;
}

.success-note {
    font-size: 14px;
    color: #6b7280;
    font-style: italic;
}

.success-disclaimer {
    margin-top: 32px;
    padding: 20px;
    background: #fef3c7;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
}

.disclaimer-emphasis {
    font-size: 15px;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 8px;
}

.disclaimer-detail {
    font-size: 14px;
    color: #78350f;
    line-height: 1.5;
    margin: 0;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .form-container {
        padding: 24px 16px;
    }

    .form-title {
        font-size: 24px;
    }

    .form-description {
        font-size: 14px;
    }

    .form-section {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }

    .form-section-title {
        font-size: 18px;
        margin-bottom: 20px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }

    .form-group-half,
    .form-group-quarter {
        flex: 1;
        margin-bottom: 20px;
    }

    .form-group {
        margin-bottom: 20px;
    }

    .form-input {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .form-select {
        padding-right: 32px;
        background-position: right 10px center;
    }

    .form-textarea {
        min-height: 100px;
    }

    .form-success {
        margin: 40px auto;
        padding: 24px 16px;
    }

    .success-title {
        font-size: 20px;
    }

    .success-disclaimer {
        margin-top: 24px;
        padding: 16px;
    }

    .disclaimer-emphasis {
        font-size: 14px;
    }

    .disclaimer-detail {
        font-size: 13px;
    }

    .modal-content {
        padding: 24px;
    }

    .modal-header {
        font-size: 18px;
    }

    .welcome-text {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .disclaimer-item.single-check {
        padding: 12px;
    }
}

/* Tablet Responsive */
@media (min-width: 601px) and (max-width: 768px) {
    .form-row {
        gap: 12px;
    }

    .form-group-quarter {
        flex: 0 0 calc(33.333% - 8px);
    }
}