/* AdXcelerant WebUI - Custom Styles */

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #e7e8ea;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* Message Bubble Animations */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user,
.message-assistant {
    animation: messageSlideIn 0.3s ease-out;
}

/* Streaming Cursor Blink */
@keyframes cursorBlink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

.streaming-cursor::after {
    content: '|';
    animation: cursorBlink 1s infinite;
    color: #f97316;
    font-weight: bold;
}

/* Tool Status Chips */
.tool-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 9999px;
    font-size: 12px;
    color: #9d4300;
    margin-top: 8px;
    animation: messageSlideIn 0.2s ease-out;
}

.tool-status-chip.processing {
    background: #fff7ed;
}

.tool-status-chip.completed {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.tool-status-chip .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #fed7aa;
    border-top-color: #f97316;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Download Card Styles */
.download-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    margin: 12px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.download-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #fed7aa;
}

.download-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff7ed;
    border-radius: 12px;
    font-size: 24px;
}

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

.download-card-filename {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.download-card-size {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.download-card-button {
    padding: 8px 16px;
    background: #f97316;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.download-card-button:hover {
    background: #ea580c;
    transform: scale(1.02);
}

/* Attachment Preview Styles */
.attachment-preview-item {
    position: relative;
    flex-shrink: 0;
}

.attachment-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.attachment-preview-item:hover .attachment-preview-remove {
    opacity: 1;
}

.attachment-preview-name {
    font-size: 10px;
    color: #64748b;
    text-align: center;
    margin-top: 3px;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.msg-copy-btn .material-symbols-outlined {
    font-size: 14px;
}

.message-user:hover .msg-copy-btn,
.message-assistant:hover .msg-copy-btn {
    opacity: 1;
}

.msg-copy-btn:hover {
    color: #475569;
}

/* Chat List Item Styles */
.chat-list-item {
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.chat-list-item:hover {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-list-item.active {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-left: 3px solid #f97316;
}

.chat-list-item-title {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-item-timestamp {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* Message Styles */
.message-user {
    display: flex;
    flex-direction: row-reverse;
    gap: 12px;
}

.message-user .message-content {
    max-width: 100%;
    background: #f97316;
    color: white;
    padding: 16px 20px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.2);
    font-size: 14px;
    line-height: 1.6;
}

.message-user .message-meta {
    text-align: right;
    margin-top: 4px;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
    margin-right: 52px;
}

.message-assistant {
    display: flex;
    gap: 12px;
}

.message-assistant .message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #ea580c, #f97316);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.message-assistant .message-content-wrapper {
    max-width: 85%;
}

.message-assistant .message-content {
    background: white;
    padding: 20px 24px;
    border-radius: 4px 20px 20px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
}

.message-assistant .message-content p {
    margin-bottom: 12px;
}

.message-assistant .message-content p:last-child {
    margin-bottom: 0;
}

.message-assistant .message-meta {
    margin-top: 6px;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
    margin-left: 52px;
}

/* Markdown Content Styles */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    margin-top: 20px;
    margin-bottom: 12px;
    color: #1f2937;
}

.message-content h1 {
    font-size: 20px;
}

.message-content h2 {
    font-size: 18px;
}

.message-content h3 {
    font-size: 16px;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 6px 0;
}

.message-content code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #ea580c;
}

.message-content pre {
    background: #1f2937;
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
}

.message-content pre code {
    background: transparent;
    color: #e5e7eb;
    padding: 0;
    font-size: 13px;
}

.message-content blockquote {
    border-left: 4px solid #f97316;
    padding-left: 16px;
    margin: 16px 0;
    color: #6b7280;
    font-style: italic;
}

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

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

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}

.message-content th,
.message-content td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.message-content th {
    font-weight: 600;
    background: #f9fafb;
    color: #374151;
}

.message-content tr:hover {
    background: #f9fafb;
}

/* Table scroll wrapper */
.table-scroll {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* Voice Recording Animation */
.voice-recording {
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    color: #ef4444 !important;
}

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

/* Error Banner */
.error-banner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 24px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: messageSlideIn 0.3s ease-out;
}

/* Sidebar mobile overlay */
#sidebar.mobile-open {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex !important;
    z-index: 25;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

/* Report iframe container */
.report-container {
    width: 100%;
    height: 500px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    margin: 16px 0;
}

.report-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Chart container */
.chart-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    height: 300px;
}

/* Flash messages */
.flash-message {
    animation: messageSlideIn 0.3s ease-out;
}



/* Inline rename input */
.chat-rename-input {
    width: 100%;
    background: white;
    border: 1.5px solid #f97316;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #1e293b;
    outline: none;
    line-height: 1.4;
}

/* ============================================================================
   App shell layout — works on all screen sizes via flexbox
   No position:fixed hacks. The flex chain enforces bounds.

   body (row, 100dvh)
     └─ #sidebar        (fixed-width column, own scroll)
     └─ main            (flex-1, column, min-h-0)
           └─ header          (flex-shrink:0)
           └─ #chat-container (flex-1, min-h-0, overflow-y:auto)
           └─ .chat-input-bar (flex-shrink:0)
   ============================================================================ */

html {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#sidebar {
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

#chat-list {
    overflow-y: auto;
    overflow-x: hidden;
}

main {
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    flex-shrink: 0;
    overflow-x: hidden;
}

#chat-container {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 1.5rem;
}

.chat-input-bar {
    flex-shrink: 0;
    overflow-x: hidden;
}

/* ============================================================================
   Mobile (≤768px) — sidebar is hidden by default, overlay when open.
   Input bar and header use position:fixed because the sidebar overlay
   takes over the whole viewport and flexbox alone can't constrain layout.
   ============================================================================ */
@media (max-width: 768px) {
    #sidebar {
        width: 100vw !important;
        max-width: 100vw !important;
    }

    header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 30 !important;
    }

    .chat-input-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 21 !important;
        background: #f8f9fb !important;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
    }

    #chat-container {
        position: fixed !important;
        top: 57px !important;
        bottom: 5rem !important;
        left: 0 !important;
        right: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    #message-thread {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .mobile-safe-spacer {
        display: none !important;
    }
}


/* Model selector - selected state */
.model-option.selected {
    background-color: #fff7ed !important;
    border-color: #f97316 !important;
}
.model-option.selected .material-symbols-outlined {
    color: #ea580c;
}
