/* CSS Variables for tenant branding */
:root {
    --primary-color: #4CAF50; /* Default green, overridden by tenant config */
    --primary-color-hover: color-mix(in srgb, var(--primary-color) 85%, black);
    --primary-color-rgb: 76, 175, 80; /* Updated by JS when tenant config loads */
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    font-size: 16px; /* Base font size */
}

/* Chatbox container - Mobile first */
.chatbox {
    width: 100%;
    height: 100vh;
    max-width: 100%;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    background-color: #fff;
    display: flex;
    flex-direction: column;
}

/* Desktop styles */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }
    
    .chatbox {
        width: 450px;
        height: 700px;
        max-width: 90%;
        max-height: 90vh;
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* Chat header */
.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 16px;
    text-align: center;
    font-size: 18px;
    font-weight: 500;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 768px) {
    .chat-header {
        font-size: 20px;
        padding: 12px;
        min-height: auto;
    }
}

/* Progress bar */
.progress-container {
    background-color: #fff;
    padding: 8px 16px;
}

.progress-bar {
    width: 100%;
    background-color: #e0e0e0;
    height: 6px;
    border-radius: 3px;
}

.progress {
    width: 0;
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.5s ease-in-out;
    border-radius: 3px;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: #666;
    padding: 4px 0;
    font-weight: 500;
}

/* Chat area */
.chat {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

/* Message containers */
.message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 16px;
    width: 100%;
    position: relative;
}

.message-container.with-button {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 17px;
    line-height: 1.5;
}

@media (min-width: 768px) {
    .message {
        max-width: 70%;
    }
}

.message.assistant {
    background-color: #d3d3d3;
    margin-right: 10px;
    flex: 0 1 auto;
}

.message.user {
    background-color: #cce5ff;
    align-self: flex-end;
    margin-left: auto;
}

/* Avatar styles */
.assistant-avatar.greeting,
.dictionary-link,
.show-zhutzu-button,
.show-completion-zhutzu {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.4s ease;
    animation: pulse 4s infinite;
    flex-shrink: 0;
    border: none;
    background-color: transparent;
}

@media (min-width: 768px) {
    .assistant-avatar.greeting,
    .dictionary-link,
    .show-zhutzu-button,
    .show-completion-zhutzu {
        width: 90px;   /* Increased for tablets */
        height: 90px;  /* Increased for tablets */
        right: 10px;
    }
}

@media (min-width: 1024px) {
    .assistant-avatar.greeting,
    .dictionary-link,
    .show-zhutzu-button,
    .show-completion-zhutzu {
        width: 100px;
        height: 100px;
    }
}

.assistant-avatar.greeting {
    background-image: var(--avatar-greeting, url('./static/ZhutzuOne.png'));
}

.dictionary-link {
    background-image: var(--avatar-dictionary, url('./static/ZhutzuOne.png'));
    z-index: 10;
    pointer-events: auto;
}

.show-zhutzu-button {
    background-image: var(--avatar-halfway, url('./static/Zhutzu_halfway_point.png'));
}

.show-completion-zhutzu {
    background-image: var(--avatar-completion, url('./static/ZhutzuOne.png'));
}

/* Tooltips */
.dictionary-link::after {
    content: "Need help?\A Click me for definitions!";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(var(--primary-color-rgb), 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: pre;
    line-height: 1.3;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    text-align: center;
    width: max-content;
    z-index: 1000;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Add a pulsing glow effect for the dictionary avatar */
.dictionary-link {
    box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb), 0.7);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(var(--primary-color-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb), 0);
    }
}

/* Mobile speech bubble for dictionary */
@media (max-width: 767px) {
    .dictionary-link::before {
        content: "Tap for help!";
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background-color: var(--primary-color);
        color: white;
        padding: 6px 10px;
        border-radius: 16px;
        font-size: 12px;
        font-weight: 500;
        opacity: 1;
        margin-bottom: 8px;
        animation: bounce 1s ease-in-out infinite;
        white-space: nowrap;
    }
    
    /* Hide hover tooltip on mobile */
    .dictionary-link::after {
        display: none;
    }
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

@media (max-width: 767px) {
    .dictionary-link::after {
        font-size: 11px;
        padding: 6px 10px;
    }
}

.dictionary-link:hover::after {
    opacity: 1;
}

/* Animations */
@keyframes pulse {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.05); }
    100% { transform: translateY(-50%) scale(1); }
}

.assistant-avatar.greeting:hover,
.dictionary-link:hover,
.show-zhutzu-button:hover,
.show-completion-zhutzu:hover {
    animation: none;
    transform: translateY(-50%) scale(1.05);
}

/* Input box */
.input-box {
    display: flex;
    border-top: 1px solid #ccc;
    background-color: #fff;
    align-items: center;
    padding: 8px;
    gap: 8px;
}

.input-box input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    outline: none;
    font-size: 16px;
    min-height: 44px;
    appearance: none;
    -webkit-appearance: none;
    background-color: #f5f5f5;
    transition: all 0.2s ease;
}

.input-box input:focus {
    background-color: #fff;
    border-color: var(--primary-color);
}

/* Submit button styling */
.input-submit-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.input-submit-button:hover {
    background-color: var(--primary-color-hover);
    transform: scale(1.05);
}

.input-submit-button:active {
    transform: scale(0.95);
}

.input-submit-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Hide submit button when input is hidden (for multiple choice) */
.input-box input[style*="display: none"] ~ .input-submit-button {
    display: none;
}

@media (min-width: 768px) {
    .input-box {
        padding: 4px;
    }
    
    .input-box input {
        padding: 10px 16px;
        min-height: 40px;
    }
}

@media (min-width: 768px) {
    .input-box input {
        padding: 12px;
        min-height: 48px;
    }
}

/* Dictionary popup - Mobile first */
.dictionary-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
    padding: 20px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    color: #F5F5F0;
    z-index: 1000;
    border-radius: 0;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .dictionary-popup {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 850px;
        height: auto;
        max-height: 90vh;
        padding: 30px 40px;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    }
}

.dictionary-popup h3 {
    text-align: left;
    font-size: 28px;
    margin: 0 0 20px 0;
    color: var(--primary-color);
    font-weight: 500;
    width: 100%;
}

@media (min-width: 768px) {
    .dictionary-popup h3 {
        font-size: 36px;
        margin-bottom: 30px;
        width: calc(100% - 420px);
    }
}

/* Dictionary input container */
.input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-bottom: 20px;
}

/* Dictionary submit button */
.dictionary-submit-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dictionary-submit-button:hover {
    background-color: var(--primary-color-hover);
    transform: scale(1.05);
}

.dictionary-submit-button:active {
    transform: scale(0.95);
}

.dictionary-submit-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

@media (min-width: 768px) {
    .input-container {
        flex-direction: row;
        align-items: center;
        width: calc(100% - 420px);
        margin-left: 20px;
        margin-right: 20px;
        margin-bottom: 30px;
    }
}

/* Update mobile layout to show submit button inline */
@media (max-width: 767px) {
    .input-container {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    
    .dictionary-popup input {
        flex: 1;
        min-width: 0;
    }
    
    .dictionary-submit-button {
        margin-left: 8px;
    }
    
    .clear-history-btn {
        width: 100%;
        margin-top: 8px;
    }
}

.dictionary-popup input {
    flex: 1;
    padding: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #F5F5F0;
    font-size: 16px;
    transition: all 0.3s ease;
    min-height: 48px;
    appearance: none;
    -webkit-appearance: none;
}

.dictionary-popup input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.dictionary-popup input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

/* Dictionary definition area */
.dictionary-popup p {
    width: 100%;
    height: 300px;
    padding: 16px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    line-height: 1.6;
    color: #F5F5F0;
    font-size: 16px;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .dictionary-popup p {
        width: calc(100% - 420px);
        height: calc(100% - 160px);
        padding: 20px;
    }
}

.searched-term {
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Close button */
.close-button {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: background-color 0.2s ease;
    z-index: 1001;
    pointer-events: auto;
}

@media (min-width: 768px) {
    .close-button {
        top: 20px;
        right: 20px;
    }
}

.close-button:hover {
    background-color: var(--primary-color-hover);
}

/* Dictionary content */
.dictionary-content {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Zhutzu avatar in dictionary */
.zhutzu-avatar {
    display: none;
}

@media (min-width: 768px) {
    .zhutzu-avatar {
        display: block;
        position: absolute;
        right: -40px;
        top: 50%;
        transform: translateY(-50%);
        width: 400px;
        height: 600px;
        background-image: var(--avatar-dictionary, url('./static/Zhutzu_dictionary.png'));
        background-size: contain;
        background-position: center;
        background-repeat: no-repeat;
        z-index: 1000;
    }
}

/* Clear history button */
.clear-history-btn {
    padding: 12px 16px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #F5F5F0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
    position: relative;
    font-size: 16px;
    white-space: nowrap;
}

.clear-history-btn:hover {
    background-color: var(--primary-color);
}

.clear-history-btn:active {
    transform: scale(0.95);
}

/* Feedback message */
.feedback-message {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(var(--primary-color-rgb), 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    pointer-events: none;
}

.feedback-message.show {
    opacity: 1;
}

/* Search suggestions */
.search-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #3a3a3a;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    margin-top: 5px;
    z-index: 1002;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
    .search-suggestions {
        top: 140px;
        left: 40px;
        width: calc(100% - 420px);
    }
}

.suggestion-item {
    padding: 12px 16px;
    color: #F5F5F0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 16px;
}

.suggestion-item:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Thinking indicator */
.typing-animation::after {
    content: '...';
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}

.thinking-indicator {
    display: inline-block;
    margin-left: 10px;
}

.thinking-indicator span {
    animation: blink 1s infinite;
    display: inline-block;
    margin: 0 2px;
}

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

@keyframes blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Option Cards - Mobile optimized */
.options-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    align-self: flex-start;
}

@media (min-width: 768px) {
    .options-container {
        max-width: 60%;
        gap: 6px;
        padding: 6px;
    }
}

.option-card {
    background-color: white;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    position: relative;
    margin: 0;
    line-height: 1.4;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .option-card {
        padding: 8px 12px;
        min-height: 44px;
        width: fit-content;
    }
}

.option-card:hover {
    background-color: #d3d3d3;
    border-color: var(--primary-color-hover);
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(var(--primary-color-rgb), 0.2);
}

.option-card.selected {
    background-color: #d3d3d3;
    color: black;
    border-color: var(--primary-color-hover);
}

/* Add checkmark for selected cards */
.option-card::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.option-card.selected::after {
    content: '✓';
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
}

/* Active state for better touch feedback */
.option-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Desktop adjustments for option cards */
@media (min-width: 768px) {
    .option-card {
        padding: 12px 16px;
        min-height: 48px;
        max-width: fit-content;
        width: auto;
        min-width: 200px;
    }
    
    .option-card::after {
        margin-left: 16px;
    }
}

/* Subtle highlight on touch start */
.option-card.touching {
    background-color: #f8f8f8;
}

/* Action buttons */
.action-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .action-buttons {
        gap: 8px;
        padding: 8px;
    }
}

/* Submit button */
.submit-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 500;
    min-height: 48px;
    min-width: 100px;
}

.submit-button:hover {
    background-color: var(--primary-color-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Comment button */
.comment-button {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    color: #333;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 48px;
}

.comment-button:hover {
    background-color: #d3d3d3;
    border-color: var(--primary-color);
}

/* Comment section */
.comment-section {
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.comment-section.hidden {
    display: none;
}

.comment-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    font-size: 16px;
    box-sizing: border-box;
    margin: 8px 0;
    appearance: none;
    -webkit-appearance: none;
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.1);
}

/* Instruction text */
.instruction-text {
    color: var(--primary-color);
    margin: 8px 0 8px 8px;
    font-size: 17px;
    align-self: flex-start;
    font-weight: 500;
}

/* Popup modals - Mobile first */
.image-halfway-point-popup,
.completion-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #ffffff, #f5f5f5);
    padding: 20px;
    box-sizing: border-box;
    z-index: 1000;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .image-halfway-point-popup,
    .completion-popup {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: auto;
        max-width: 450px;
        height: auto;
        padding: 30px;
        border-radius: 15px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }
}

.image-halfway-point-content,
.completion-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: 50px;
}

@media (min-width: 768px) {
    .image-halfway-point-content,
    .completion-content {
        padding-top: 0;
    }
}

.image-halfway-point-content h3,
.completion-content h3 {
    color: var(--primary-color);
    font-size: 24px;
    margin: 0;
    font-weight: bold;
}

@media (min-width: 768px) {
    .image-halfway-point-content h3,
    .completion-content h3 {
        font-size: 28px;
    }
}

.halfway-point-popup-image,
.completion-zhutzu-image {
    width: 150px;
    height: auto;
    object-fit: contain;
}

@media (min-width: 768px) {
    .halfway-point-popup-image {
        width: 200px;
    }
}

.encouragement-text,
.completion-text {
    color: #333;
    font-size: 18px;
    line-height: 1.5;
    margin: 0;
    padding: 0 10px;
}

.completion-cta-button {
    display: inline-block;
    margin-top: 16px;
    padding: 12px 32px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s ease;
}
.completion-cta-button:hover {
    background-color: var(--primary-color-hover);
    transform: translateY(-1px);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -48%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes surfFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes celebrateFloat {
    0% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(5deg); }
    50% { transform: translateY(0) rotate(0deg); }
    75% { transform: translateY(-10px) rotate(-5deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

.halfway-point-popup-image {
    animation: surfFloat 3s ease-in-out infinite;
}

.completion-zhutzu-image {
    animation: celebrateFloat 4s ease-in-out infinite;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.image-halfway-point-popup.closing,
.completion-popup.closing {
    animation: fadeOut 0.3s ease-out forwards;
}

/* Welcome Form - Mobile First */
#welcomeForm {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(120deg, #f5f5f5, #e0e0e0);
    padding: 20px;
    box-sizing: border-box;
}

#contactForm {
    width: 100%;
    max-width: 500px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    padding: 24px;
    text-align: center;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    #contactForm {
        padding: 30px;
    }
}

#contactForm h2 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 600;
    line-height: 1.3;
}

@media (min-width: 768px) {
    #contactForm h2 {
        font-size: 28px;
        margin-bottom: 25px;
    }
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 16px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    box-sizing: border-box;
    min-height: 48px;
    appearance: none;
    -webkit-appearance: none;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}

.consent-group {
    display: flex;
    align-items: flex-start;
    margin: 25px 0;
    text-align: left;
    gap: 12px;
}

.consent-group input[type="checkbox"] {
    margin-top: 2px;
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.consent-group label {
    font-size: 16px;
    color: #333;
    line-height: 1.4;
}

.start-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 14px 30px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    min-height: 48px;
    width: 100%;
    max-width: 200px;
}

.start-btn:hover {
    background-color: var(--primary-color-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.start-btn:active {
    transform: translateY(0);
}

.brand-logo {
    width: 70px;
    height: 70px;
    margin: 0 auto 15px;
    background-image: var(--avatar-dictionary, url('./static/ZhutzuOne.png'));
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Custom scrollbar */
.dictionary-popup p::-webkit-scrollbar,
.chat::-webkit-scrollbar {
    width: 6px;
}

.dictionary-popup p::-webkit-scrollbar-track,
.chat::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.dictionary-popup p::-webkit-scrollbar-thumb,
.chat::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-color-rgb), 0.3);
    border-radius: 3px;
}

.dictionary-popup p::-webkit-scrollbar-thumb:hover,
.chat::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-color-rgb), 0.5);
}

/* Prevent iOS zoom on input focus */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .chatbox {
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    .input-box {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}
