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

body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    direction: rtl;
}

.chat-container {
    width: 100%;
    max-width: 500px;
    height: 90vh;
    height: 90dvh;
    max-height: 700px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Mobile: fill the full screen */
@media (max-width: 520px) {
    body {
        align-items: stretch;
        background: #fff;
    }

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

    .chat-input {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
}

.chat-header {
    background: #061538;
    color: #fff;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Account for iPhone notch/status bar */
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.header-dot {
    width: 10px;
    height: 10px;
    background: #34d399;
    border-radius: 50%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
}

.bubble {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
    animation: fadeIn 0.3s ease;
    text-align: right;
}

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

.bubble.bot {
    align-self: flex-end;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-right-radius: 4px;
}

.bubble.user {
    align-self: flex-start;
    background: #061538;
    color: #fff;
    border-bottom-left-radius: 4px;
}

.chat-input {
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 60px;
    align-items: center;
    direction: rtl;
}

.chat-input input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
    outline: none;
    transition: border-color 0.2s;
    direction: rtl;
    text-align: right;
}

.chat-input input[type="text"]:focus {
    border-color: #061538;
}

.send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: #061538;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #0a2255;
}

.option-btn {
    padding: 8px 18px;
    background: #fff;
    border: 2px solid #061538;
    color: #061538;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.option-btn:hover {
    background: #061538;
    color: #fff;
}

.rating-btn {
    width: 40px;
    height: 40px;
    background: #fff;
    border: 2px solid #f59e0b;
    color: #f59e0b;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.2s;
}

.rating-btn:hover {
    background: #f59e0b;
    color: #fff;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    align-self: flex-end;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* File upload styles */
.file-upload-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    color: #6b7280;
    font-size: 13px;
    transition: all 0.2s;
    text-align: center;
}

.file-upload-label:hover {
    border-color: #061538;
    color: #061538;
}

.file-upload-label .upload-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.file-upload-label input[type="file"] {
    display: none;
}

.file-name-display {
    font-size: 12px;
    color: #061538;
    font-weight: 500;
}

.file-error {
    font-size: 12px;
    color: #ef4444;
}

.upload-progress {
    font-size: 12px;
    color: #6b7280;
}
