/* Copied from static/styles.css for isolated frontend */
:root {
	--bg: #ffffff;
	--panel: #111827;
	--text: #e5e7eb;
	--muted: #9ca3af;
	--accent: #3b82f6;
	--accent-2: #60a5fa;
	--danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
	background: var(--bg);
	color: var(--text);
}

.container {
	max-width: 960px;
	margin: 0 auto;
	padding: 24px 16px;
}

.card {
	background: var(--panel);
	border: 1px solid #1f2937;
	border-radius: 10px;
	padding: 16px;
	box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

h1 { font-size: 20px; margin: 0 0 12px; }

.row { display: flex; gap: 8px; }
input[type="text"] {
	flex: 1;
	background: #0b1220;
	border: 1px solid #1f2937;
	color: var(--text);
	border-radius: 8px;
	padding: 10px 12px;
}
button, select {
	background: var(--accent);
	color: white;
	border: none;
	border-radius: 8px;
	padding: 10px 12px;
	cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.secondary { background: #374151; }
button.danger { background: var(--danger); }

.error { color: #fecaca; margin-top: 8px; }

.chat {
	height: 60vh;
	overflow: auto;
	padding: 12px;
	background: #0b1220;
	border: 1px solid #1f2937;
	border-radius: 10px;
}

/* Printing/export helpers */
.print-container { position: absolute; left: -99999px; top: 0; width: 800px; }
.bubble { break-inside: avoid; page-break-inside: avoid; }


.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.export-btn { background: transparent; border: 1px solid #374151; color: var(--text); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.export-btn:hover { background: #1f2937; }

.bubble {
	max-width: 75%;
	margin: 8px 0;
	padding: 10px 12px;
	border-radius: 12px;
	line-height: 1.4;
}
.bubble.user { background: #1d4ed8; color: white; margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.bot { background: #111827; border: 1px solid #1f2937; color: var(--text); margin-right: auto; border-bottom-left-radius: 4px; }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Markdown content styling inside bubbles */
.bubble h1, .bubble h2, .bubble h3 { margin: 6px 0; }
.bubble p { margin: 6px 0; }
.bubble ul, .bubble ol { margin: 6px 0 6px 18px; }
.bubble code { background: #0b1220; padding: 2px 4px; border-radius: 4px; border: 1px solid #1f2937; }
.bubble pre { background: #0b1220; padding: 8px; border-radius: 8px; border: 1px solid #1f2937; overflow: auto; }
.bubble pre code { background: transparent; border: none; }

.seek-container {
	margin: 12px 0;
	padding: 16px;
	background: #1f2937;
	border-radius: 8px;
	border: 1px solid #374151;
}
.seek-bar {
	width: 100%;
	height: 8px;
	background: #374151;
	border-radius: 4px;
	position: relative;
	cursor: pointer;
	margin: 8px 0;
}
.seek-progress {
	height: 100%;
	background: var(--accent);
	border-radius: 4px;
	transition: width 0.1s ease;
}
.seek-thumb {
	position: absolute;
	top: -4px;
	width: 16px;
	height: 16px;
	background: var(--accent);
	border-radius: 50%;
	border: 2px solid white;
	box-shadow: 0 2px 4px rgba(0,0,0,0.3);
	cursor: grab;
	transition: transform 0.1s ease;
}
.seek-thumb:hover { transform: scale(1.2); }
.seek-thumb:active { cursor: grabbing; }
.seek-info {
	display: flex;
	justify-content: space-between;
	font-size: 12px;
	color: var(--muted);
	margin-top: 4px;
}
.seek-tooltip {
	position: absolute;
	top: -30px;
	left: 50%;
	transform: translateX(-50%);
	background: #0f172a;
	color: var(--text);
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 11px;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s;
	border: 1px solid #374151;
}
.seek-thumb:hover .seek-tooltip { opacity: 1; }
.chat-indicator {
    position: absolute;
    top: -2px;
    width: 4px;
    height: 12px;
    background: #f97316; /* Orange color */
    border-radius: 2px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.chat-indicator:hover {
    background: #fb923c; /* Lighter orange on hover */
    transform: translateX(-50%) scale(1.2);
}

/* Ensure the indicators are visible above the progress bar */
.seek-bar {
    position: relative;
    z-index: 1;
}

.seek-progress {
    position: relative;
    z-index: 1;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-btn {
    position: relative;
    background: transparent;
    border: 1px solid #374151;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.header-btn:hover {
    background: #1f2937;
    border-color: var(--accent);
}

.header-btn .badge {
    background: var(--accent);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

/* Message Images */
.message-images {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #374151;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.pinned-indicator {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
    opacity: 0.8;
}

/* Image Lightbox */
.image-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 12px;
}

/* Pinned Messages Sidebar */
.pinned-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: var(--panel);
    border-left: 1px solid #1f2937;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.pinned-sidebar[aria-hidden="false"] {
    transform: translateX(0);
}

.pinned-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #1f2937;
}

.pinned-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.pinned-close {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.pinned-close:hover {
    background: #1f2937;
}

.pinned-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.pinned-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.pinned-hint {
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.7;
}

.pinned-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pinned-message-item {
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.pinned-message-item:hover {
    background: #1f2937;
    border-color: var(--accent);
    transform: translateX(-4px);
}

.pinned-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

.pinned-icon {
    font-size: 14px;
}

.pinned-role {
    font-weight: 600;
    color: var(--accent);
}

.pinned-time {
    margin-left: auto;
    color: var(--muted);
    font-size: 11px;
}

.pinned-message-preview {
    color: var(--text);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pinned-jump-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

.pinned-jump-btn:hover {
    background: var(--accent-2);
}

/* Document Library Panel */
.document-library-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--panel);
    border-left: 1px solid #1f2937;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.document-library-panel[aria-hidden="false"] {
    transform: translateX(0);
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #1f2937;
}

.library-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.library-close {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.library-close:hover {
    background: #1f2937;
}

.library-controls {
    padding: 16px;
    border-bottom: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-search {
    width: 100%;
    background: #0b1220;
    border: 1px solid #1f2937;
    color: var(--text);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
}

.library-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.library-filters button {
    background: #0b1220;
    border: 1px solid #1f2937;
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.library-filters button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.library-filters button:hover:not(.active) {
    background: #1f2937;
}

.library-view-toggle {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.library-view-toggle button {
    background: #0b1220;
    border: 1px solid #1f2937;
    color: var(--text);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.library-view-toggle button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.library-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.library-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.library-documents {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-documents.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.library-document-item {
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.library-documents.list .library-document-item {
    flex-direction: row;
    align-items: center;
    text-align: left;
}

.library-document-item:hover {
    background: #1f2937;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.library-doc-thumbnail {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: #0b1220;
}

.library-doc-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-doc-icon {
    font-size: 32px;
}

.library-doc-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-width: 0;
}

.library-doc-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-doc-type {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .pinned-sidebar,
    .document-library-panel {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .pinned-sidebar,
    .document-library-panel {
        width: 100%;
        height: 70vh;
        top: auto;
        bottom: 0;
        border-left: none;
        border-top: 1px solid #1f2937;
        transform: translateY(100%);
    }
    
    .pinned-sidebar[aria-hidden="false"],
    .document-library-panel[aria-hidden="false"] {
        transform: translateY(0);
    }
    
    .header-actions {
        flex-wrap: wrap;
    }
    
    .header-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .message-image {
        max-height: 200px;
    }
    
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
