/**
 * Custom styles for Tinode Chat
 * Extends Tailwind with app-specific styles
 */

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Sidebar scrollbar */
#sidebar ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

#sidebar ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Message input auto-resize */
#message-input {
    min-height: 24px;
    line-height: 1.5;
}

/* Typing indicator dots animation */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-right: 8px;
}

.typing-dots .dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Message content styling */
.message-content {
    line-height: 1.5;
}

.message-content p {
    margin: 0;
}

.message-content p + p {
    margin-top: 0.5em;
}

.message-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875em;
}

.message-content pre {
    margin: 0.5em 0;
    padding: 0.75em;
    background: #1e1e1e;
    border-radius: 6px;
    overflow-x: auto;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: #d4d4d4;
}

.message-content a {
    color: #1264a3;
    text-decoration: none;
}

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

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content blockquote {
    margin: 0.5em 0;
    padding-left: 1em;
    border-left: 3px solid #e2e8f0;
    color: #64748b;
}

/* Message actions visibility */
.message-item .message-actions {
    opacity: 0;
    transition: opacity 0.15s ease;
}

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

/* Consecutive message styling */
.message-item.consecutive {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* Unread indicator line */
.unread-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    color: #ef4444;
    font-size: 0.75rem;
    font-weight: 500;
}

.unread-indicator::before,
.unread-indicator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ef4444;
}

/* Toast transitions */
#toast-container > div {
    animation: toast-in 0.3s ease forwards;
}

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

/* Sidebar section transitions */
#channels-list,
#dms-list {
    transition: max-height 0.2s ease;
    overflow: hidden;
}

/* Active channel highlight */
#channels-list > div.bg-slack-sidebarActive,
#dms-list > div.bg-slack-sidebarActive {
    font-weight: 500;
}

/* Search result hover */
#search-results > div {
    transition: background-color 0.15s ease;
}

/* Modal backdrop */
#login-modal,
#search-modal,
#create-channel-modal {
    backdrop-filter: blur(4px);
}

/* Loading spinner */
.loading-spinner {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

/* Right panel transitions */
#right-panel {
    transition: width 0.2s ease, opacity 0.2s ease;
}

/* Mobile responsive */
@media (max-width: 1024px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 40;
        transform: translateX(0);
        transition: transform 0.3s ease;
    }

    #sidebar.hidden {
        transform: translateX(-100%);
    }

    #right-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 40;
    }
}

@media (max-width: 768px) {
    #right-panel {
        width: 100%;
    }
}

/* Focus styles */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #1264a3;
    outline-offset: 2px;
}

/* Placeholder styling */
::placeholder {
    color: #9ca3af;
}

.dark ::placeholder {
    color: #6b7280;
}

/* Selection styling */
::selection {
    background: #1264a3;
    color: white;
}

/* Avatar placeholder colors */
.avatar-bg-1 { background-color: #6366f1; }
.avatar-bg-2 { background-color: #8b5cf6; }
.avatar-bg-3 { background-color: #ec4899; }
.avatar-bg-4 { background-color: #ef4444; }
.avatar-bg-5 { background-color: #f97316; }
.avatar-bg-6 { background-color: #eab308; }
.avatar-bg-7 { background-color: #22c55e; }
.avatar-bg-8 { background-color: #14b8a6; }
.avatar-bg-9 { background-color: #06b6d4; }
.avatar-bg-10 { background-color: #3b82f6; }

/* Emoji picker integration placeholder */
emoji-picker {
    --background: #fff;
    --border-color: #e2e8f0;
}

.dark emoji-picker {
    --background: #1f2937;
    --border-color: #374151;
}

/* File drop zone */
.file-drop-zone {
    border: 2px dashed #cbd5e1;
    transition: border-color 0.2s, background-color 0.2s;
}

.file-drop-zone.drag-over {
    border-color: #1264a3;
    background-color: rgba(18, 100, 163, 0.1);
}

/* Mention autocomplete */
.mention-autocomplete,
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark .mention-autocomplete,
.dark .mention-dropdown {
    background: #1f2937;
    border-color: #374151;
}

.mention-dropdown::-webkit-scrollbar {
    width: 6px;
}

.mention-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.dark .mention-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.mention-item {
    transition: background-color 0.1s ease;
}

/* Image preview in messages */
.message-content img {
    max-width: 400px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

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

/* Connection status pulse */
#connection-dot.bg-slack-online {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(43, 172, 118, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(43, 172, 118, 0);
    }
}

/* Keyboard shortcut hints */
.shortcut-hint {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    font-family: ui-monospace, monospace;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    color: #64748b;
}

.dark .shortcut-hint {
    background: #374151;
    border-color: #4b5563;
    color: #9ca3af;
}
