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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: transparent;
}

#chat-app {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

/* Invalid Widget */
.invalid-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 2rem;
    text-align: center;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}

.invalid-widget-icon {
    width: 80px;
    height: 80px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}

.invalid-widget-icon svg {
    width: 40px;
    height: 40px;
    fill: white;
}

.invalid-widget h2 {
    color: #991b1b;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.invalid-widget p {
    color: #b91c1c;
    font-size: 0.875rem;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #d1fae5;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-state p {
    color: #059669;
    font-weight: 500;
}

/* ==================== PRE-CHAT FORM STYLES ==================== */
.prechat-form-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
    overflow-y: auto;
}

.prechat-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.prechat-header-avatar {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    overflow: hidden;
}

.prechat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prechat-header-avatar svg {
    width: 36px;
    height: 36px;
    fill: white;
}

.prechat-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.prechat-header p {
    font-size: 0.875rem;
    opacity: 0.9;
}

.prechat-form {
    padding: 1.5rem;
    flex: 1;
}

.form-intro {
    text-align: center;
    margin-bottom: 1.5rem;
}

.form-intro h3 {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.form-intro p {
    font-size: 0.875rem;
    color: #64748b;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-group label .required {
    color: #ef4444;
    margin-left: 2px;
}

.form-group label .optional {
    color: #9ca3af;
    font-weight: 400;
    font-size: 0.75rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9ca3af;
}

.form-group input.error,
.form-group textarea.error {
    border-color: #ef4444;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.error-message {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.submit-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.submit-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ==================== CHAT INTERFACE STYLES ==================== */

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.2);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reload-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.reload-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    transform: rotate(180deg);
}

.reload-btn:active {
    transform: rotate(180deg) scale(0.95);
}

.reload-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.reload-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.new-conversation-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.new-conversation-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

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

.new-conversation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.new-conversation-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-header-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.chat-header-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.chat-header-info span {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

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

.chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Messages */
.message {
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bot {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
}

.message-content {
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-bot .message-content {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message-user .message-content {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

/* User Info Message (the first message with collected info) */
.user-info-content {
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
    font-size: 0.875rem;
}

.user-info-content .info-row {
    margin-bottom: 0.375rem;
}

.user-info-content .info-row:last-child {
    margin-bottom: 0;
}

.user-info-content .info-label {
    opacity: 0.85;
}

.user-info-content .initial-message {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-style: italic;
}

.message-time {
    font-size: 0.6875rem;
    color: #94a3b8;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

.message-user .message-time {
    text-align: right;
}

/* Question Options */
.question-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.question-option {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.question-option:hover {
    border-color: #10b981;
    background: #f0fdf4;
    transform: translateX(4px);
}

.question-option:active {
    transform: scale(0.98) translateX(4px);
}

.question-option-icon {
    width: 28px;
    height: 28px;
    background: #ecfdf5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.question-option-icon svg {
    width: 14px;
    height: 14px;
    fill: #10b981;
}

.question-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.875rem 1rem;
    background: white;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 1.5rem;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.attachment-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: color 0.2s ease;
}

.attachment-btn:hover {
    color: #10b981;
}

.attachment-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f1f5f9;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.attachment-preview-info {
    flex: 1;
    min-width: 0;
}

.attachment-preview-name {
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-preview-size {
    font-size: 0.75rem;
    color: #64748b;
}

.attachment-preview-remove {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-preview-remove:hover {
    color: #dc2626;
}

.attachment-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.attachment-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-icon svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Media Message Styles (Images and Videos) */
.media-message {
    margin-top: 0.5rem;
    border-radius: 0.75rem;
    overflow: hidden;
    max-width: 100%;
}

.message-media-image {
    min-width: 100%;
    max-width: 200px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-media-image:hover {
    transform: scale(1.02);
}

.message-media-video {
    max-width: 100%;
    max-height: 200px;
    width: 100%;
    border-radius: 0.75rem;
    display: block;
    background: #000;
}

.media-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.5rem;
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.media-error svg {
    flex-shrink: 0;
}

.agent-joined-notice {
    background: #dbeafe;
    border-left: 3px solid #3b82f6;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #1e40af;
    text-align: center;
}

.chat-input input:focus {
    border-color: #10b981;
}

.chat-input input::placeholder {
    color: #94a3b8;
}

.chat-input input:disabled {
    background: #f8fafc;
    cursor: not-allowed;
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Welcome Message */
.welcome-container {
    text-align: center;
    padding: 1.5rem;
}

.welcome-emoji {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    animation: wave 1.5s infinite;
    display: inline-block;
}

@keyframes wave {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(20deg);
    }

    75% {
        transform: rotate(-10deg);
    }
}

.welcome-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.5;
}

/* Restart Button */
.restart-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0 auto;
    transition: color 0.2s;
}

.restart-btn:hover {
    color: #10b981;
}

.restart-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* User Input Form (for "ask" type questions) */
.user-input-form {
    margin-top: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

.user-input-container {
    background: white;
    border: 2px solid #10b981;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.user-input-field {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
    margin-bottom: 0.75rem;
}

.user-input-field:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.user-input-field::placeholder {
    color: #94a3b8;
}

.user-input-field:disabled {
    background: #f8fafc;
    cursor: not-allowed;
    opacity: 0.7;
}

.user-input-field[type="date"] {
    cursor: pointer;
}

.user-input-submit-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.user-input-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.user-input-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.user-input-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.user-input-submit-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.input-required-text {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.5rem;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

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