/**
 * Generic Chat Component Styles
 *
 * A complete, standalone CSS file for the Generic Chat Component.
 * Import this file on any page where you want to use the chat.
 *
 * Usage:
 * <link rel="stylesheet" href="/static/css/generic-chat.css">
 */

/* ==============================================
   CHAT CONTAINER & PANEL
   ============================================== */

.generic-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ==============================================
   CHAT HEADER
   ============================================== */

.chat-header {
    padding: 1rem 1.5rem;
    background: rgba(0, 102, 204, 0.2);
    border-bottom: 1px solid rgba(0, 217, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    color: var(--secondary, #00d9ff);
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--secondary, #00d9ff);
    color: white;
}

/* ==============================================
   CHAT TOOLBAR
   ============================================== */

.chat-toolbar {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-toolbar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--secondary, #00d9ff);
    color: white;
}

.chat-toolbar-btn i {
    font-size: 0.9rem;
}

.chat-search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.chat-search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
}

.chat-search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
}

.chat-search-box input:focus {
    outline: none;
    border-color: var(--secondary, #00d9ff);
    background: rgba(255, 255, 255, 0.08);
}

/* ==============================================
   CHAT ANALYTICS
   ============================================== */

.chat-analytics {
    padding: 1rem 1.5rem;
    background: rgba(0, 102, 204, 0.1);
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
    display: none;
}

.chat-analytics.visible {
    display: block;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.analytics-stat {
    text-align: center;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.analytics-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary, #00d9ff);
    margin-bottom: 0.25rem;
}

.analytics-stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==============================================
   TEMPLATES PANEL
   ============================================== */

.templates-panel {
    padding: 1rem 1.5rem;
    background: rgba(0, 102, 204, 0.1);
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.templates-panel.visible {
    display: block;
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.templates-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.template-name {
    font-weight: 600;
    color: var(--secondary, #00d9ff);
    margin-bottom: 0.25rem;
}

.template-preview {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
}

.template-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.template-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--secondary, #00d9ff);
    color: white;
}

/* ==============================================
   QUICK REPLIES
   ============================================== */

.quick-replies {
    padding: 0.75rem 1rem;
    background: rgba(0, 102, 204, 0.1);
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
    display: none;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quick-replies.visible {
    display: flex;
}

.quick-reply-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 217, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.quick-reply-btn:hover {
    background: rgba(0, 217, 255, 0.2);
    border-color: var(--secondary, #00d9ff);
    color: white;
    transform: translateY(-1px);
}

/* ==============================================
   CHAT MESSAGES
   ============================================== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 217, 255, 0.3);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 217, 255, 0.5);
}

.chat-message {
    max-width: 80%;
    padding: 1rem;
    border-radius: 12px;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.3), rgba(0, 153, 255, 0.3));
    border: 1px solid rgba(0, 217, 255, 0.3);
}

.chat-message.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-message.system {
    align-self: center;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    max-width: 90%;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 193, 7, 0.9);
}

.message-content {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #00d9ff;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content a {
    color: var(--secondary, #00d9ff);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* ==============================================
   MESSAGE TIMESTAMP
   ============================================== */

.message-timestamp {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.4rem;
    display: block;
}

/* ==============================================
   MESSAGE ACTIONS
   ============================================== */

.message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.message-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--secondary, #00d9ff);
    color: white;
}

.message-action-btn i {
    margin-right: 0.25rem;
}

/* ==============================================
   MESSAGE REACTIONS
   ============================================== */

.message-reactions {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.reaction-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.reaction-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.reaction-btn.active {
    background: rgba(0, 217, 255, 0.3);
    border-color: var(--secondary, #00d9ff);
}

.reaction-count {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ==============================================
   PINNED MESSAGES
   ============================================== */

.message-pinned {
    border-left: 4px solid #ffc107 !important;
    background: rgba(255, 193, 7, 0.1) !important;
    position: relative;
}

.pin-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: #ffc107;
    font-size: 0.9rem;
}

/* ==============================================
   SEARCH HIGHLIGHTING
   ============================================== */

.chat-message.highlighted {
    animation: highlightPulse 1s ease;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
}

@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(0, 217, 255, 0.8);
    }
}

/* ==============================================
   TYPING INDICATOR
   ============================================== */

.typing-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    max-width: 100px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--secondary, #00d9ff);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

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

/* ==============================================
   CHAT INPUT AREA
   ============================================== */

.chat-input-area {
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.formatting-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.format-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.format-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--secondary, #00d9ff);
    color: white;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: 0.75rem;
}

.autocomplete-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 60px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

.autocomplete-suggestions.visible {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.2s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: rgba(0, 217, 255, 0.1);
}

.autocomplete-text {
    color: white;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.autocomplete-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 50px;
    max-height: 150px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: var(--secondary, #00d9ff);
    background: rgba(255, 255, 255, 0.08);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.voice-input-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 217, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.voice-input-btn:hover {
    background: rgba(0, 217, 255, 0.1);
    border-color: var(--secondary, #00d9ff);
    color: var(--secondary, #00d9ff);
}

.voice-input-btn.recording {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    color: #ef4444;
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

.send-btn {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.8), rgba(0, 153, 255, 0.8));
    border: 1px solid rgba(0, 217, 255, 0.3);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.95rem;
}

.send-btn:hover {
    background: linear-gradient(135deg, rgba(0, 102, 204, 1), rgba(0, 153, 255, 1));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

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

.char-counter {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
    padding: 0.25rem 0.5rem;
}

.char-counter.warning {
    color: #ffcc00;
}

.char-counter.error {
    color: #ff4444;
}

/* ==============================================
   FILE UPLOAD
   ============================================== */

.file-upload-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.file-upload-label {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-upload-label:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--secondary, #00d9ff);
    color: white;
}

.file-upload-input {
    display: none;
}

/* ==============================================
   DRAG & DROP OVERLAY
   ============================================== */

.chat-drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 217, 255, 0.1);
    border: 3px dashed var(--secondary, #00d9ff);
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}

.chat-drop-overlay.active {
    display: flex;
}

.drop-message {
    background: rgba(0, 0, 0, 0.8);
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
}

.drop-message i {
    font-size: 3rem;
    color: var(--secondary, #00d9ff);
    margin-bottom: 1rem;
}

.drop-message p {
    color: white;
    font-size: 1.1rem;
    margin: 0;
}

/* ==============================================
   EXPORT FORMAT SELECTOR
   ============================================== */

.export-format-selector {
    position: relative;
    display: inline-block;
}

.export-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: none;
    min-width: 120px;
    z-index: 100;
}

.export-dropdown.visible {
    display: block;
}

.export-option {
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.export-option:last-child {
    border-bottom: none;
}

.export-option:hover {
    background: rgba(0, 217, 255, 0.1);
    color: white;
}

/* ==============================================
   RESPONSIVE DESIGN
   ============================================== */

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

    .chat-toolbar {
        flex-direction: column;
    }

    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .formatting-toolbar {
        flex-wrap: wrap;
    }
}

/* ==============================================
   TOAST NOTIFICATIONS (Fallback)
   ============================================== */

.generic-chat-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-success {
    background: #4caf50;
    color: white;
}

.toast-error {
    background: #f44336;
    color: white;
}

.toast-info {
    background: #2196f3;
    color: white;
}
