/* --- SlideSearcher Styles --- */

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f3f4f6;
    margin: 0;
}

/* Layout */
.sidebar {
    width: 400px;
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    transition: width 0.3s;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: #525659;
    overflow: hidden;
}

/* Thumbnail Panel */
.thumbnail-panel {
    width: 140px;
    background: #1f2937;
    border-right: 1px solid #374151;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.thumbnail-panel.hidden {
    display: none;
}

.thumbnail-header {
    padding: 12px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thumbnail-toggle {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.thumbnail-toggle:hover {
    background: #374151;
}

.thumbnail-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.thumbnail-list::-webkit-scrollbar {
    width: 6px;
}

.thumbnail-list::-webkit-scrollbar-thumb {
    background-color: #4b5563;
    border-radius: 3px;
}

.thumbnail-item {
    cursor: pointer;
    margin-bottom: 12px;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.2s;
    background: #374151;
}

.thumbnail-item:hover {
    border-color: #60a5fa;
    transform: scale(1.02);
}

.thumbnail-item.active {
    border-color: #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.thumbnail-item canvas {
    width: 100%;
    display: block;
    border-radius: 2px;
}

.thumbnail-page-num {
    text-align: center;
    font-size: 10px;
    color: #9ca3af;
    padding: 4px 0;
    background: #374151;
    border-radius: 0 0 2px 2px;
}

/* PDF Viewer Area */
.pdf-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 40px;
    scroll-behavior: smooth;
    text-align: center;
}

.pdf-page-container {
    display: inline-block;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: white;
    transition: all 0.3s ease;
    position: relative;
}

/* 選択中のPDFファイルの外枠を強調 */
.pdf-file-selected {
    border-left: 4px solid #3b82f6;
    background-color: #eff6ff;
    font-weight: 600;
}

.page-focus {
    box-shadow: 0 0 0 4px #3b82f6, 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* --- Text Layer --- */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 1;
    line-height: 1.0;
}

.textLayer>span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

/* Highlight Style */
.txt-highlight {
    background-color: rgba(255, 230, 0, 0.6);
    border-radius: 2px;
    box-shadow: 0 0 3px rgba(255, 230, 0, 0.6);
}

.page-label {
    position: absolute;
    top: -25px;
    left: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
}

canvas {
    display: block;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    color: white;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.zoom-text {
    font-size: 14px;
    min-width: 48px;
    text-align: center;
}

/* Sidebar UI */
.card {
    padding: 14px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
}

.card:hover {
    background-color: #f9fafb;
    padding-left: 18px;
    border-left: 4px solid #3b82f6;
}

.card h4 {
    margin: 0 0 6px 0;
    font-size: 15px;
    color: #1f2937;
    font-weight: 700;
}

.card p {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

.tag {
    display: inline-flex;
    align-items: center;
    background: #eff6ff;
    color: #2563eb;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 6px;
    margin-top: 6px;
    font-weight: 500;
}

.loader {
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top: 3px solid #3b82f6;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}

/* D&D Overlay */
#dropOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(59, 130, 246, 0.9);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
    pointer-events: none;
}

#dropOverlay.active {
    display: flex;
}

/* Chat UI */
#chatContainer {
    min-height: 0;
}

#chatHistory {
    min-height: 0;
}

.chat-message {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-user {
    background-color: #f9fafb;
    color: #1f2937;
}

.chat-ai {
    background-color: #ffffff;
    color: #374151;
}

.chat-ai strong {
    color: #2563eb;
}

.page-link {
    color: #2563eb;
    font-weight: 700;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 4px;
    transition: background 0.2s;
}

.page-link:hover {
    text-decoration: underline;
    background-color: #eff6ff;
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

/* ===== Modal Styles ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.modal-lg {
    max-width: 640px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header button {
    font-size: 24px;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    z-index: 300;
}

.context-menu.hidden {
    display: none;
}

/* ===== Annotation Toolbar ===== */
.annotation-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.annotation-toolbar.hidden {
    display: none;
}

.annotation-tool-group {
    display: flex;
    gap: 4px;
}

.annotation-tool {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.annotation-tool:hover {
    background: rgba(255, 255, 255, 0.2);
}

.annotation-tool.active {
    background: rgba(59, 130, 246, 0.5);
}

.annotation-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.3);
}

.stamp-selector,
.note-color-selector {
    display: flex;
    gap: 4px;
}

.stamp-selector.hidden,
.note-color-selector.hidden {
    display: none;
}

.stamp-option {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.stamp-option:hover {
    background: rgba(255, 255, 255, 0.3);
}

.stamp-option.active {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.8);
    transform: scale(1.1);
}

.note-color-option {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.note-color-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.note-color-option.active {
    border-color: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8);
    transform: scale(1.15);
}

/* ===== Sticky Notes ===== */
.sticky-note {
    position: absolute;
    min-width: 120px;
    min-height: 80px;
    max-width: 250px;
    padding: 8px 10px;
    padding-right: 24px;
    /* 削除ボタンのスペース確保 */
    border-radius: 4px;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 12px;
    line-height: 1.4;
    cursor: grab;
    z-index: 20;
    resize: both;
    overflow: auto;
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.sticky-note:focus-within {
    outline: 2px solid #3b82f6;
}

.sticky-note-text {
    min-height: 60px;
    outline: none;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.sticky-note-delete {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    color: #6b7280;
    pointer-events: none;
    z-index: 10;
}

.sticky-note:hover .sticky-note-delete {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Stamps ===== */
.stamp {
    position: absolute;
    font-size: 28px;
    cursor: grab;
    user-select: none;
    z-index: 20;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
    transition: transform 0.1s;
}

.stamp:hover {
    transform: scale(1.1);
}

.stamp-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.stamp:hover .stamp-delete {
    opacity: 1;
}

/* ===== Hierarchical Index ===== */
.index-category {
    border-bottom: 1px solid #e5e7eb;
}

.index-category-header {
    padding: 10px 14px;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    transition: background 0.2s;
}

.index-category-header:hover {
    background: #f3f4f6;
}

.index-category-header .arrow {
    transition: transform 0.2s;
}

.index-category.collapsed .arrow {
    transform: rotate(-90deg);
}

.index-category.collapsed .index-category-items {
    display: none;
}

.index-category-count {
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
}

.index-category-items {
    padding: 0;
}

.index-item {
    padding: 10px 14px 10px 24px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
}

.index-item:hover {
    background: #f9fafb;
    padding-left: 28px;
    border-left: 3px solid #3b82f6;
}

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

.index-item-keyword {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 4px;
}

.index-item-summary {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

/* ===== Workspace List ===== */
.workspace-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.workspace-item:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
}

.workspace-item.active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.workspace-item-name {
    font-weight: 500;
    font-size: 14px;
}

.workspace-item-date {
    font-size: 11px;
    color: #9ca3af;
}

.workspace-item-delete {
    color: #9ca3af;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.workspace-item-delete:hover {
    color: #ef4444;
    background: #fee2e2;
}

/* ===== Search Match Score ===== */
.search-score {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
}

.search-score-high {
    background: #dcfce7;
    color: #16a34a;
}

.search-score-medium {
    background: #fef3c7;
    color: #d97706;
}

.search-score-low {
    background: #fee2e2;
    color: #dc2626;
}

/* ===== Prose Styles for Summary ===== */
.prose h1,
.prose h2,
.prose h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.prose p {
    margin-bottom: 0.75em;
}

.prose ul,
.prose ol {
    margin-left: 1.5em;
    margin-bottom: 0.75em;
}

.prose li {
    margin-bottom: 0.25em;
}

/* Index Source Tags */
.index-item-source {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.file-tag {
    background: #dbeafe;
    color: #1e40af;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-tag {
    background: #f3f4f6;
    color: #4b5563;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Loading Button State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-loading span {
    visibility: hidden;
}

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

/* Ask Question Button */
.ask-question-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    transition: all 0.2s;
}

.ask-question-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Chat Quote Area */
.chat-quote-area {
    background: #f3f4f6;
    border-left: 3px solid #3b82f6;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.chat-quote-text {
    flex: 1;
    font-size: 12px;
    color: #374151;
    line-height: 1.4;
    max-height: 60px;
    overflow-y: auto;
}

.chat-quote-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.chat-quote-close:hover {
    color: #6b7280;
}

/* Chat Quote Display (in chat history) */
.chat-quote-display {
    background: #e5e7eb;
    border-left: 3px solid #3b82f6;
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #4b5563;
    font-style: italic;
    line-height: 1.4;
}

/* ===== Chat Sidebar ===== */
.chat-sidebar {
    width: 200px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s, margin-left 0.3s;
    overflow: hidden;
}

.chat-sidebar.hidden {
    width: 0;
    margin-left: -1px;
    border-right: none;
}

.chat-sidebar-header {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f3f4f6;
}

.chat-new-btn {
    font-size: 11px;
    background: #3b82f6;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-new-btn:hover {
    background: #2563eb;
}

.chat-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-session-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chat-session-item:hover {
    background: #e5e7eb;
}

.chat-session-item.active {
    background: #dbeafe;
    color: #1e40af;
}

.chat-session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-session-delete {
    opacity: 0;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    transition: opacity 0.2s, color 0.2s;
}

.chat-session-item:hover .chat-session-delete {
    opacity: 1;
}

.chat-session-delete:hover {
    color: #ef4444;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9fafb;
}

.chat-sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #6b7280;
    transition: background 0.2s, color 0.2s;
}

.chat-sidebar-toggle:hover {
    background: #e5e7eb;
    color: #374151;
}

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