: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):hover {
    background: #6b7280;
}

.send-button.active {
    background: var(--chat-primary-button);
}

.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;
}

.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:hover {
    background-color: #f9fafb;
}

.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;
}

.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;
}

.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);
}