/* ==================== BASE & RESET ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ==================== BACKGROUND & LAYOUT ==================== */
/* Beige/off-white background with logo watermark */
.bg-gradient {
    background: linear-gradient(180deg, #f5f3f0 0%, #faf8f5 100%);
    position: relative;
    overflow: hidden;
}

/* Logo watermark in background */
.bg-gradient::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('/assets/lexi-logo.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 40%;
    opacity: 0.08;
    filter: grayscale(100%) brightness(0.3);
    pointer-events: none;
}

@keyframes backgroundShift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-10px, -10px) scale(1.01); }
}

/* ==================== GLASSMORPHISM EFFECTS ==================== */
/* Header with beige tint - 10% darker */
.glass-header {
    background: rgba(235, 233, 230, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: none;
    box-shadow: none;
    position: relative;
    z-index: 20;
}

/* Input area */
.glass-input {
    background: rgba(255, 255, 255, 1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    min-height: 36px;
    overflow: visible;
}

/* Footer area */
.glass-footer {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid rgba(226, 232, 240, 0.6);
}

/* ==================== CONTENT AREAS ==================== */
/* Content area styling for tab merge - no gaps */
#chatContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#redliningContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#settingsContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

#draftingContent {
    background: #ffffff;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* ==================== SCROLLBARS ==================== */
/* Custom scrollbar - Subtle modern */
#chatContainer::-webkit-scrollbar {
    width: 6px;
}

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

#chatContainer::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 10px;
}

#chatContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* Custom scrollbar for drafting chat container */
#draftChatContainer::-webkit-scrollbar {
    width: 6px;
}

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

#draftChatContainer::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 10px;
}

#draftChatContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* Custom scrollbar for redlining list */
#redliningIssuesList::-webkit-scrollbar {
    width: 5px;
}

#redliningIssuesList::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.4);
    border-radius: 10px;
}

#redliningIssuesList::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 10px;
}

#redliningIssuesList::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

/* Custom scrollbar for settings panel */
#settingsPanel::-webkit-scrollbar {
    width: 6px;
}

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

#settingsPanel::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.5);
    border-radius: 10px;
}

#settingsPanel::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* ==================== ANIMATIONS ==================== */
/* Smooth animations */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

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

.spinner {
    width: 16px;
    height: 16px;
    background-image: url('/assets/lexi-logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: spin 1s linear infinite;
}

/* Larger spinner for email search, redlining, etc. */
#emailSearchLoadingState .spinner {
    width: 24px;
    height: 24px;
}

/* Small spinner for inline loading states */
.spinner-small {
    width: 12px;
    height: 12px;
    background-image: url('/assets/lexi-logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

/* Inverted spinner for dark backgrounds */
.spinner-inverted {
    filter: invert(1) brightness(2);
}

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

/* Tailwind-style animate-spin for compatibility */
.animate-spin {
    animation: spin 1s linear infinite;
}

/* ==================== MESSAGE BUBBLES ==================== */
/* Clean modern theme with subtle beige */
.message-user {
    background: #f3f0ec;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    color: #000000;
}

.message-assistant {
    background: rgba(248, 250, 252, 0.8);
    box-shadow: none;
    border: 1px solid rgba(226, 232, 240, 0.6);
}

/* ==================== BUTTONS ==================== */
/* Modern focus effect with stone/beige */
.glow-focus:focus {
    outline: none;
    border-color: rgba(87, 83, 78, 0.5);
    box-shadow: 0 0 0 3px rgba(87, 83, 78, 0.1);
}

/* Button styles - Solid modern with beige/stone */
.btn-primary {
    background: #57534e;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover:not(:disabled) {
    background: #44403c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(68, 64, 60, 0.25);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Action buttons - Modern clean style */
.btn-action {
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-action:hover {
    background: rgba(248, 250, 252, 1);
    border-color: rgba(203, 213, 225, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.btn-accept {
    color: #16a34a;
}

.btn-accept:hover {
    background: rgba(240, 253, 244, 1);
    border-color: rgba(34, 197, 94, 0.4);
}

.btn-reject {
    color: #dc2626;
}

.btn-reject:hover {
    background: rgba(254, 242, 242, 1);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Header action buttons */
.header-action-btn {
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-action-btn:hover {
    background: rgba(241, 245, 249, 0.8);
    color: #475569;
}

.header-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Icon button styling */
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(241, 245, 249, 0.8);
    color: #475569;
}

/* ==================== ATTACHMENT INDICATORS ==================== */
.attachment-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
}
.attachment-badge svg {
    flex-shrink: 0;
}
.attachment-badge-count {
    font-weight: 600;
}

/* ==================== MESSAGE ATTACHMENT CHIPS (inside user bubble) ==================== */
.msg-attach-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.msg-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: #78716c;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1;
    letter-spacing: 0.01em;
}
.msg-attach-chip svg {
    opacity: 0.7;
    flex-shrink: 0;
}

/* ==================== TOOL STATUS OVERLAY ==================== */
.tool-status-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}
.tool-status-overlay:not(:empty) {
    padding: 6px 12px;
    background: linear-gradient(transparent, rgba(255,255,255,0.95) 20%);
}
.tool-status-overlay > * {
    pointer-events: auto;
}

/* ==================== MARKDOWN CONTENT ==================== */
.markdown-content h1 { font-size: 16px; font-weight: 700; margin: 8px 0 4px; }
.markdown-content h2 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; }
.markdown-content h3 { font-size: 13px; font-weight: 600; margin: 6px 0 3px; }
.markdown-content p { margin: 4px 0; }
.markdown-content > :first-child { margin-top: 0; padding-top: 0; line-height: 1.4; }
.markdown-content ul { margin: 4px 0; padding-left: 20px; list-style-type: disc; }
.markdown-content ol { margin: 4px 0; padding-left: 20px; list-style-type: decimal; }
.markdown-content li { margin: 2px 0; display: list-item; }
.markdown-content strong { font-weight: 600; }
.markdown-content em { font-style: italic; }
.markdown-content code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}
.markdown-content pre {
    background: #f1f5f9;
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
}
.markdown-content pre code {
    background: none;
    padding: 0;
}
.markdown-content blockquote {
    border-left: 3px solid #cbd5e1;
    padding-left: 10px;
    margin: 6px 0;
    color: #64748b;
}
.markdown-content a {
    color: #2563eb;
    text-decoration: underline;
}
.markdown-content hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 8px 0;
}
.markdown-content table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 12px;
    width: 100%;
}
.markdown-content th, .markdown-content td {
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    text-align: left;
}
.markdown-content th {
    background: #f8fafc;
    font-weight: 600;
}

/* ==================== LOADING STATUS ==================== */
.loading-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    animation: loadingPulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Hidden state */
.hidden {
    display: none;
}
