/* Root Colors & Constants */
:root {
    --primary-color: #ff3366;
    --primary-hover: #e02454;
    --primary-light: #fff0f3;
    
    --bg-app: #f4f6f9;
    --bg-chat: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.85);
    
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-white: #ffffff;
    
    --border-color: #e5e7eb;
    
    --bubble-user: #ff3366;
    --bubble-user-text: #ffffff;
    --bubble-bot: #f3f4f6;
    --bubble-bot-text: #1f2937;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 20px 25px -5px rgba(255, 51, 102, 0.1), 0 10px 10px -5px rgba(255, 51, 102, 0.04);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Layout Wrapper */
.chat-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Chat Main Container (Typebot Style) */
.chat-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    background-color: var(--bg-chat);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: none;
}

@media (min-width: 641px) {
    .chat-container {
        height: 92vh;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        border: 1px solid var(--border-color);
        overflow: hidden;
    }
}

/* Header Styling */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
    position: sticky;
    top: 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    position: relative;
    width: 42px;
    height: 42px;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #ff3366, #ff7b90);
    color: var(--text-white);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(255, 51, 102, 0.3);
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-chat);
}

.status-dot.online {
    background-color: #10b981;
}

.status-dot.offline {
    background-color: var(--text-muted);
}

.header-text {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-action {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover {
    color: var(--text-main);
    background-color: var(--bg-app);
}

/* Support hold banner */
.support-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #fef3c7;
    color: #92400e;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid #fde68a;
    animation: fadeIn 0.3s ease;
}

.support-banner.hidden {
    display: none;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-chat);
    display: flex;
    flex-direction: column;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    gap: 16px;
    flex: 1;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: auto 0;
    padding: 20px 10px;
    max-width: 420px;
    align-self: center;
    animation: slideUp 0.5s ease;
}

.welcome-logo {
    width: 68px;
    height: 68px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #ff3366, #ff7b90);
    color: var(--text-white);
    font-size: 26px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow-premium);
}

.welcome-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.welcome-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

.suggested-prompts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.suggested-btn {
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggested-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* Message Bubbles */
.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 4px;
    animation: slideIn 0.3s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.message-row.user .message-bubble {
    background-color: var(--bubble-user);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 4px;
}

.message-row.bot .message-bubble {
    background-color: var(--bubble-bot);
    color: var(--bubble-bot-text);
    border-bottom-left-radius: 4px;
}

/* Media in Messages */
.message-media {
    margin-top: 8px;
    border-radius: var(--radius-md);
    overflow: hidden;
    max-width: 100%;
    display: block;
}

.message-media img {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

.message-media video {
    max-width: 100%;
    max-height: 250px;
    border-radius: var(--radius-md);
    display: block;
}

/* Document/File Card in Messages */
.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    margin-top: 8px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

.message-row.user .file-card {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.file-card:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.message-row.user .file-card:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.file-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background-color: var(--primary-color);
    color: var(--text-white);
    display: flex;
    justify-content: center;
    align-items: center;
}

.message-row.user .file-card-icon {
    background-color: var(--text-white);
    color: var(--primary-color);
}

.file-card-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-card-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.file-card-size {
    font-size: 11px;
    opacity: 0.7;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background-color: var(--text-muted);
    border-radius: var(--radius-full);
    opacity: 0.4;
    animation: typingPulse 1.4s infinite ease-in-out both;
}

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

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

/* Audio Player Bubble Custom Style */
.audio-player-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
    padding: 4px 0;
}

.audio-play-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    background-color: var(--text-white);
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.message-row.user .audio-play-btn {
    background-color: var(--text-white);
    color: var(--primary-color);
}

.message-row.bot .audio-play-btn {
    background-color: var(--primary-color);
    color: var(--text-white);
}

.audio-waveform-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.audio-duration {
    font-size: 10px;
    opacity: 0.8;
}

.audio-waveform-progress {
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.message-row.user .audio-waveform-progress {
    background-color: rgba(255, 255, 255, 0.3);
}

.audio-waveform-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background-color: currentColor;
    border-radius: 2px;
}

/* Footer & Input Form */
.chat-footer {
    padding: 12px 16px 24px;
    background-color: var(--bg-chat);
    border-top: 1px solid var(--border-color);
    z-index: 10;
}

@media (max-width: 640px) {
    .chat-footer {
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
}

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    position: relative;
}

.btn-input-action {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-input-action:hover {
    color: var(--primary-color);
    background-color: var(--primary-light);
}

.btn-mic.recording {
    background-color: #ef4444;
    color: var(--text-white) !important;
    animation: pulseMic 1.5s infinite;
}

.input-container {
    flex: 1;
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--primary-color);
    background-color: var(--bg-chat);
    box-shadow: 0 0 0 3px rgba(255, 51, 102, 0.1);
}

.input-container textarea {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.4;
    max-height: 100px;
    padding: 2px 0;
}

.btn-send {
    background-color: var(--primary-color);
    border: none;
    color: var(--text-white);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(255, 51, 102, 0.2);
}

.btn-send:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.btn-send:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Hidden Utility */
.hidden {
    display: none !important;
}

/* Attachment Preview container */
.attachment-preview-container {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background-color: #fafbfc;
    display: flex;
}

.preview-item {
    position: relative;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    background-color: var(--bg-chat);
    display: flex;
    align-items: center;
}

.preview-item img {
    height: 60px;
    width: auto;
    object-fit: cover;
}

.file-preview-card {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    color: var(--text-main);
}

.file-icon {
    color: var(--primary-color);
}

.file-name-text {
    font-size: 12px;
    font-weight: 500;
    max-width: 150px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-remove-attachment {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--text-white);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

.btn-remove-attachment:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Voice Recording Overlay */
.voice-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-chat);
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 20;
    animation: slideUp 0.2s ease;
}

.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.voice-wave .bar {
    width: 3px;
    background-color: var(--primary-color);
    border-radius: 1px;
    animation: wavePulse 1s ease-in-out infinite alternate;
}

.voice-wave .bar:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.voice-wave .bar:nth-child(2) { height: 16px; animation-delay: 0.3s; }
.voice-wave .bar:nth-child(3) { height: 10px; animation-delay: 0.5s; }
.voice-wave .bar:nth-child(4) { height: 20px; animation-delay: 0.2s; }
.voice-wave .bar:nth-child(5) { height: 14px; animation-delay: 0.4s; }
.voice-wave .bar:nth-child(6) { height: 8px; animation-delay: 0.6s; }

.voice-status {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: var(--radius-full);
    animation: flash 1s infinite alternate;
}

#recording-timer {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.recording-label {
    color: var(--text-muted);
}

.btn-cancel-voice {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.btn-cancel-voice:hover {
    background-color: var(--bg-app);
    color: var(--text-main);
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes typingPulse {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@keyframes wavePulse {
    from { transform: scaleY(0.4); }
    to { transform: scaleY(1.2); }
}

@keyframes flash {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

@keyframes pulseMic {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
