/**
 * DocuChat AI - Chat Interface Styles
 * Dark theme with gradient background
 */

/* CSS Reset for chat pages */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* CSS Variables */
:root {
    --dc-bg-1: #1A1A2E;
    --dc-bg-2: #16213E;
    --dc-bg-3: #0F3460;
    --dc-primary: #6C63FF;
    --dc-secondary: #00D9FF;
    --dc-text: #FFFFFF;
    --dc-text-muted: rgba(255, 255, 255, 0.7);
    --dc-bot-bg: rgba(255, 255, 255, 0.1);
    --dc-user-bg: #6C63FF;
    --dc-input-bg: rgba(255, 255, 255, 0.1);
    --dc-border: rgba(255, 255, 255, 0.1);
    --dc-error: #FF6B6B;
    --dc-success: #4CD964;
    /* Multilingual font stack */
    --dc-font-family: 'Noto Sans Telugu', 'Noto Sans Devanagari', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Full page chat container */
.docuchat-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dc-bg-1) 0%, var(--dc-bg-2) 50%, var(--dc-bg-3) 100%);
    font-family: var(--dc-font-family);
    color: var(--dc-text);
    display: flex;
    flex-direction: column;
}

/* Embedded chat container */
.docuchat-embed-container {
    background: linear-gradient(135deg, var(--dc-bg-1) 0%, var(--dc-bg-2) 50%, var(--dc-bg-3) 100%);
    font-family: var(--dc-font-family);
    color: var(--dc-text);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Header */
.docuchat-header {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--dc-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Back Button */
.docuchat-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--dc-text);
    text-decoration: none;
    font-size: 20px;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.docuchat-back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.docuchat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.docuchat-logo {
    font-size: 28px;
    flex-shrink: 0;
}

.docuchat-title-group {
    min-width: 0;
}

.docuchat-title {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.docuchat-subtitle {
    font-size: 12px;
    color: var(--dc-text-muted);
}

/* Header Right Section */
.docuchat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.docuchat-badge {
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-secondary));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Category Badge */
.docuchat-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.docuchat-category-badge:empty {
    display: none;
}

.docuchat-category-badge.individual {
    background: rgba(108, 99, 255, 0.2);
    color: #A5A0FF;
}

.docuchat-category-badge.hospital {
    background: rgba(0, 217, 255, 0.2);
    color: #5EE7FF;
}

.docuchat-category-badge.doctor {
    background: rgba(0, 191, 166, 0.2);
    color: #5CD6C5;
}

/* Message Limit Badge */
.docuchat-message-limit {
    background: rgba(255, 255, 255, 0.15);
    color: var(--dc-text-muted);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.docuchat-message-limit:empty {
    display: none;
}

.docuchat-message-limit.warning {
    background: rgba(255, 107, 107, 0.2);
    color: #FF6B6B;
}

/* Clear History Button */
.docuchat-clear-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    padding: 6px 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.docuchat-clear-btn:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.15);
    transform: scale(1.05);
}

.docuchat-clear-btn:active {
    transform: scale(0.95);
}

/* Wishlist Button in Chat Header */
.docuchat-wishlist-btn {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    padding: 6px 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.docuchat-wishlist-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}

.docuchat-wishlist-btn.wishlisted {
    opacity: 1;
}

/* Wishlist Toast Notification */
.wishlist-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #2a2a3e, #1e1e2e);
    border: 1px solid var(--dc-border);
    color: var(--dc-text);
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

.wishlist-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Language Selector */
#language-selector {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    font-family: var(--dc-font-family);
    transition: background 0.2s, border-color 0.2s;
}

#language-selector:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

#language-selector:focus {
    outline: none;
    border-color: var(--dc-primary);
}

#language-selector option {
    background: #1e1e2e;
    color: white;
    padding: 8px;
}

/* Messages Area */
.docuchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.docuchat-messages::-webkit-scrollbar {
    width: 6px;
}

.docuchat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.docuchat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Message Bubbles */
.docuchat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.docuchat-message.bot {
    align-self: flex-start;
}

.docuchat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.docuchat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.docuchat-message.bot .docuchat-avatar {
    background: var(--dc-bot-bg);
}

.docuchat-message.user .docuchat-avatar {
    background: var(--dc-primary);
}

.docuchat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.6;
    word-wrap: break-word;
    font-family: var(--dc-font-family);
}

.docuchat-message.bot .docuchat-bubble {
    background: var(--dc-bot-bg);
    border-bottom-left-radius: 4px;
}

.docuchat-message.user .docuchat-bubble {
    background: var(--dc-user-bg);
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.docuchat-typing {
    display: flex;
    gap: 12px;
    align-self: flex-start;
    max-width: 85%;
}

.docuchat-typing .docuchat-avatar {
    background: var(--dc-bot-bg);
}

.docuchat-typing-dots {
    background: var(--dc-bot-bg);
    padding: 16px 20px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.docuchat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--dc-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.docuchat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.docuchat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.docuchat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Input Area */
.docuchat-input-area {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 16px 20px;
    border-top: 1px solid var(--dc-border);
    position: sticky;
    bottom: 0;
}

.docuchat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--dc-input-bg);
    border-radius: 25px;
    padding: 4px 4px 4px 20px;
    border: 1px solid var(--dc-border);
    transition: border-color 0.2s ease;
}

.docuchat-input-wrapper:focus-within {
    border-color: var(--dc-primary);
}

.docuchat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--dc-text);
    font-size: 16px;
    padding: 12px 0;
    outline: none;
}

.docuchat-input::placeholder {
    color: var(--dc-text-muted);
}

.docuchat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-secondary));
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.docuchat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

.docuchat-send-btn:active {
    transform: scale(0.95);
}

.docuchat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Voice Chat Button */
.docuchat-voice-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--dc-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.docuchat-voice-btn:hover {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.3), rgba(0, 217, 255, 0.3));
    border-color: var(--dc-primary);
    color: var(--dc-text);
    transform: scale(1.05);
}

.docuchat-voice-btn:active {
    transform: scale(0.95);
}

.docuchat-voice-btn svg {
    width: 20px;
    height: 20px;
}

/* Loading Screen */
.docuchat-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--dc-bg-1) 0%, var(--dc-bg-2) 50%, var(--dc-bg-3) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 1000;
}

.docuchat-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--dc-border);
    border-top-color: var(--dc-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.docuchat-loading-text {
    font-size: 18px;
    color: var(--dc-text-muted);
}

/* Error Screen */
.docuchat-error-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--dc-bg-1) 0%, var(--dc-bg-2) 50%, var(--dc-bg-3) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1000;
    padding: 20px;
    text-align: center;
}

.docuchat-error-icon {
    font-size: 64px;
}

.docuchat-error-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--dc-error);
}

.docuchat-error-message {
    font-size: 16px;
    color: var(--dc-text-muted);
    max-width: 400px;
}

.docuchat-error-btn {
    margin-top: 16px;
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-secondary));
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.docuchat-error-btn:hover {
    transform: scale(1.05);
}

/* Embedded loading state */
.docuchat-embed-container .docuchat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.docuchat-embed-container .docuchat-spinner {
    width: 40px;
    height: 40px;
}

/* Error message in embedded mode */
.docuchat-error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid var(--dc-error);
    color: var(--dc-error);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

/* Hidden utility */
.docuchat-hidden {
    display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .docuchat-header {
        padding: 12px 16px;
    }

    .docuchat-back-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .docuchat-title {
        font-size: 16px;
        max-width: 150px;
    }

    .docuchat-category-badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    .docuchat-message-limit {
        font-size: 11px;
        padding: 3px 10px;
    }

    .docuchat-messages {
        padding: 16px;
    }

    .docuchat-message {
        max-width: 90%;
    }

    .docuchat-input-area {
        padding: 12px 16px;
    }

    .docuchat-input {
        font-size: 16px;
    }
}

/* Markdown support in messages */
.docuchat-bubble p {
    margin: 0 0 8px 0;
}

.docuchat-bubble p:last-child {
    margin-bottom: 0;
}

.docuchat-bubble code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
}

.docuchat-bubble pre {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.docuchat-bubble pre code {
    background: none;
    padding: 0;
}

.docuchat-bubble ul,
.docuchat-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.docuchat-bubble li {
    margin: 4px 0;
}

.docuchat-bubble strong {
    font-weight: 600;
}

.docuchat-bubble em {
    font-style: italic;
}