/* ========================================
   AI 編目系統樣式
   國立中興大學圖書館
   ======================================== */

:root {
    /* 中興大學配色 - 綠色系為主 */
    --nchu-green: #006633;
    --nchu-green-light: #008844;
    --nchu-green-dark: #004d26;
    --nchu-gold: #c9a227;
    --nchu-gold-light: #d4b545;

    /* 主色調 */
    --primary-color: #006633;
    --primary-light: #e8f5e9;
    --primary-hover: #004d26;
    --secondary-color: #64748b;
    --accent-color: #c9a227;

    /* 狀態色 */
    --success-color: #16a34a;
    --warning-color: #ea580c;
    --danger-color: #dc2626;
    --info-color: #0284c7;

    /* 背景與表面 */
    --background-color: #f5f7f5;
    --surface-color: #ffffff;
    --surface-elevated: #ffffff;

    /* 文字色 */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* 邊框與陰影 */
    --border-color: #e2e8f0;
    --border-radius: 0.75rem;
    --border-radius-lg: 1rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* 漸層 */
    --gradient-primary: linear-gradient(135deg, #006633 0%, #008844 100%);
    --gradient-accent: linear-gradient(135deg, #c9a227 0%, #d4b545 100%);
    --gradient-dark: linear-gradient(135deg, #004d26 0%, #006633 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   歡迎畫面
   ======================================== */
.cataloging-welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.5s ease-out;
    overflow: hidden;
}

.welcome-bg-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(201, 162, 39, 0.1) 0%, transparent 30%);
    pointer-events: none;
}

.cataloging-welcome-overlay.hidden {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.cataloging-welcome-modal {
    text-align: center;
    color: white;
    animation: slideUp 0.6s ease-out;
    z-index: 1;
    padding: 2rem;
}

.welcome-logo-container {
    margin-bottom: 1.5rem;
}

.welcome-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.05em;
}

.welcome-subtitle {
    font-size: 1.25rem;
    opacity: 0.95;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.welcome-description {
    font-size: 1rem;
    opacity: 0.85;
    max-width: 400px;
    margin: 0 auto 2rem;
    letter-spacing: 0.02em;
}

.welcome-loading {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.welcome-loading-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-color);
    border-radius: 2px;
    animation: loadingProgress 1.8s ease-out forwards;
}

@keyframes loadingProgress {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

.welcome-footer {
    position: absolute;
    bottom: 2rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    letter-spacing: 0.1em;
}

/* ========================================
   主容器
   ======================================== */
.cataloging-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--background-color);
}

/* ========================================
   左側邊欄
   ======================================== */
.cataloging-sidebar {
    width: 300px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

.sidebar-header {
    padding: 1.25rem;
    background: var(--gradient-primary);
    color: white;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.sidebar-logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.brand-subtitle {
    font-size: 0.8rem;
    opacity: 0.85;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 1rem 0;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.sidebar-icon {
    font-size: 1.25rem;
}

.new-cataloging-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.new-cataloging-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cataloging-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: linear-gradient(180deg, #f8faf8 0%, #f5f7f5 100%);
}

.cataloging-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cataloging-item-content {
    flex: 1;
    min-width: 0;
}

.cataloging-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cataloging-item:hover {
    background-color: #f8faf8;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.cataloging-item:hover::before {
    opacity: 1;
}

.cataloging-item.active {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
}

.cataloging-item.active::before {
    opacity: 1;
}

.cataloging-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.cataloging-item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cataloging-item-delete {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.cataloging-item-delete:hover {
    background: var(--danger-color);
    color: white;
    opacity: 1;
    transform: scale(1.1);
}

.cataloging-item-delete:active {
    transform: scale(0.95);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8faf8;
}

.sidebar-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stats-icon {
    font-size: 1rem;
}

.back-to-home-link {
    display: block;
    margin-top: 0.75rem;
    padding: 0.5rem;
    text-align: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.back-to-home-link:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

/* ========================================
   主要內容區 (full-width after sidebar removal)
   ======================================== */
.cataloging-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg, #f8faf8 0%, #f5f7f5 100%);
    width: 100%;
    max-width: 100%;
}

.cataloging-header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-info h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon {
    font-size: 1.5rem;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--gradient-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 2rem;
    letter-spacing: 0.02em;
}

.current-task {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.header-btn:hover {
    background-color: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.header-btn.logout-btn:hover {
    background-color: #fef2f2;
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* ========================================
   編目內容區
   ======================================== */
.cataloging-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.cataloging-section {
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.cataloging-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-suggest-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 102, 51, 0.3);
}

.ai-suggest-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 102, 51, 0.4);
}

.ai-suggest-btn:active {
    transform: translateY(0);
}

.ai-suggest-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 表單樣式 */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.required {
    color: var(--danger-color);
    margin-left: 0.25rem;
}

.form-input,
.form-textarea {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
    background-color: white;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 51, 0.15);
    background-color: #fafbfc;
}

.form-textarea {
    resize: vertical;
}

.editable-suggestion {
    background-color: #faf9f7;
}

/* AI 編目建議區域 */
.ai-suggestions {
    margin-top: 1.5rem;
}

.suggestion-card {
    background: linear-gradient(135deg, #f0f7f3 0%, #e8f5ec 100%);
    border: 1px solid rgba(0, 102, 51, 0.15);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.suggestion-content {
    display: grid;
    gap: 1rem;
}

.suggestion-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: start;
}

.suggestion-item.full-width {
    grid-column: 1 / -1;
}

.suggestion-item>label {
    font-weight: 600;
    color: var(--text-secondary);
    padding-top: 0.75rem;
    white-space: nowrap;
}

.suggestion-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* 標籤容器 */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
    min-height: 44px;
    align-content: center;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gradient-primary);
    color: white;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 102, 51, 0.2);
}

.tag-remove {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.tag-remove:hover {
    opacity: 1;
}

/* 參考書籍列表 */
.reference-books-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reference-book-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.reference-book-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.book-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: var(--gradient-primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.book-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.book-title {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.book-title strong {
    font-weight: 600;
}

/* 書籍超連結樣式 */
.book-link {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary-color);
    transition: all 0.2s ease;
}

.book-link:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
    border-bottom-style: solid;
}

.book-link:visited {
    color: var(--nchu-green-dark);
}

.ai-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--gradient-accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.book-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.book-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.book-call-number {
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #f0f7f3 0%, #e8f5ec 100%);
    border-left: 3px solid var(--primary-color);
    border-radius: 0.375rem;
    font-family: 'Courier New', monospace;
}

.call-number-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.call-number-value {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-left: 0.5rem;
}

.book-reason {
    padding: 0.5rem 0.75rem;
    background: rgba(201, 162, 39, 0.1);
    border-left: 3px solid var(--accent-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.reference-books-note {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--primary-light);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 館藏連結按鈕 */
.catalog-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.catalog-link-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* 建議選項中的參考書籍連結 */
.ref-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed var(--primary-color);
    transition: all 0.2s ease;
}

.ref-link:hover {
    color: var(--primary-hover);
    border-bottom-style: solid;
}

.ref-catalog-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 0.25rem;
    border: 1px solid var(--primary-color);
    transition: all 0.2s ease;
}

.ref-catalog-link:hover {
    background: var(--primary-color);
    color: white;
}

/* 加載狀態 */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

.ai-loading p {
    color: var(--text-secondary);
    font-weight: 500;
}

/* 提示信息 */
.suggestion-hint {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.hint-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* 操作按鈕 */
.cataloging-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: var(--background-color);
    border-top: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
}

.action-btn span {
    font-size: 1.125rem;
}

.save-btn {
    background-color: var(--accent-color);
    color: white;
}

.save-btn:hover {
    background-color: #b8922a;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.submit-btn {
    background: var(--gradient-primary);
    color: white;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 102, 51, 0.4);
}

.clear-btn {
    background-color: #f5f5f5;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.clear-btn:hover {
    background-color: #e5e7eb;
    color: var(--text-primary);
}

/* 對話區域 */
.cataloging-chat {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.chat-message {
    margin-bottom: 1rem;
    animation: slideUp 0.3s ease-out;
}

.chat-message.user {
    text-align: right;
}

.chat-message-content {
    display: inline-block;
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
}

.chat-message.user .chat-message-content {
    background: var(--gradient-primary);
    color: white;
}

.chat-message.assistant .chat-message-content {
    background-color: var(--background-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--background-color);
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    max-height: 120px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 51, 0.15);
}

.chat-send-btn {
    padding: 0.75rem 1.25rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 幫助模態框 */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background-color: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    margin: 1rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.modal-close:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 1.5rem;
}

.help-section {
    margin-bottom: 1.5rem;
}

.help-section h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.help-section p,
.help-section li {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.help-section ul,
.help-section ol {
    margin-left: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 102, 51, 0.4);
}

/* 提示信息 */
.success-toast,
.error-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out;
    z-index: 9000;
}

.success-toast {
    background-color: var(--success-color);
    color: white;
}

.error-toast {
    background-color: var(--danger-color);
    color: white;
}

.toast-icon {
    font-size: 1.25rem;
}

/* 動畫 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .cataloging-sidebar {
        width: 240px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .cataloging-container {
        flex-direction: column;
    }

    .cataloging-sidebar {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions button {
        flex: 1;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .cataloging-actions {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
    }

    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }

    .success-toast,
    .error-toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .cataloging-content {
        padding: 1rem;
    }

    .cataloging-section {
        padding: 1rem;
    }

    .welcome-title {
        font-size: 2rem;
    }

    .welcome-icon {
        font-size: 4rem;
    }
}

/* 相似書籍區塊 */
.similar-books-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f0f7f3;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.similar-books-section p strong {
    color: var(--primary-color);
    font-size: 1rem;
}

.similar-books-list {
    list-style: none;
    padding: 0;
    margin-top: 0.75rem;
}

.similar-book-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background-color: white;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.similar-book-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.similar-book-item .book-index {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 1.5rem;
}

.similar-book-item .book-title {
    font-weight: 500;
    color: var(--text-primary);
}

.similar-book-item .book-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.similar-book-item .book-callnumber {
    margin-left: auto;
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    font-weight: 500;
}

/* 分析資訊區塊 */
.analysis-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f0fdf4;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--success-color);
}

.analysis-section p strong {
    color: var(--success-color);
    font-size: 1rem;
}

.analysis-section ul {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
}

.analysis-section li {
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

/* 建議詳情區塊 */
.suggestion-detail {
    padding: 1rem;
    background-color: #fffbeb;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--warning-color);
}

.suggestion-detail p strong {
    color: var(--warning-color);
}

.suggestion-detail p {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

/* ========================================
   通知動畫
   ======================================== */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification {
    font-weight: 500;
    font-size: 0.95rem;
}

/* ========================================
   多建議選項樣式
   ======================================== */
.suggestions-options-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.suggestions-header {
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.suggestions-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.suggestions-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.suggestion-option {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
}

.suggestion-option:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.suggestion-option.recommended {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, #fffef7 0%, #fffdf0 100%);
}

.suggestion-option.selected {
    border-color: var(--success-color);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.suggestion-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8faf8 0%, #f0f5f0 100%);
    border-bottom: 1px solid var(--border-color);
}

.suggestion-option.recommended .suggestion-option-header {
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
}

.suggestion-option-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.recommended-badge {
    background: var(--gradient-accent);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.option-number {
    font-weight: 600;
    color: var(--primary-color);
}

.option-name {
    font-weight: 500;
    color: var(--text-primary);
}

.suggestion-confidence {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 500;
}

.confidence-high {
    background: #dcfce7;
    color: #166534;
}

.confidence-medium {
    background: #fef9c3;
    color: #854d0e;
}

.confidence-low {
    background: #fee2e2;
    color: #991b1b;
}

.suggestion-option-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .suggestion-info-grid {
        grid-template-columns: 1fr;
    }
}

.suggestion-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.info-value.call-number {
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
}

.suggestion-reason {
    background: #f8faf8;
    padding: 1rem;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.reason-label {
    font-weight: 600;
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.suggestion-reason p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.suggestion-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.tags-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tag-chip {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.suggestion-references {
    background: #fffbeb;
    padding: 1rem;
    border-radius: var(--border-radius);
}

.references-label {
    font-weight: 600;
    color: var(--accent-color);
    display: block;
    margin-bottom: 0.5rem;
}

.reference-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reference-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.ref-title {
    color: var(--text-primary);
    font-weight: 500;
}

.ref-callnumber {
    background: var(--primary-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.ref-reason {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.suggestion-option-footer {
    padding: 1rem 1.25rem;
    background: #f8faf8;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.select-suggestion-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-suggestion-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.suggestion-option.selected .select-suggestion-btn {
    background: var(--success-color);
}

.search-summary {
    background: #f0f9ff;
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid #bae6fd;
}

.search-summary summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--info-color);
}

.search-summary p {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========================================
   索書號產生器樣式
   ======================================== */
.call-number-builder {
    background: linear-gradient(135deg, #f0f7f3 0%, #e8f5ec 100%);
    border: 1px solid rgba(0, 102, 51, 0.15);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(0, 102, 51, 0.2);
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button .form-input {
    flex: 1;
}

.generate-btn,
.assemble-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.generate-btn {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 102, 51, 0.25);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 51, 0.35);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.assemble-btn {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 2px 8px rgba(201, 162, 39, 0.25);
}

.assemble-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 162, 39, 0.35);
}

.input-with-prefix {
    display: flex;
    align-items: center;
}

.input-prefix {
    padding: 0.625rem 0.75rem;
    background: linear-gradient(135deg, #e8f5ec 0%, #d1fae5 100%);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.input-with-prefix .form-input {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.call-number-display {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
    letter-spacing: 0.05em;
}

.field-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.375rem;
}

/* ========================================
   響應式調整 - 索書號產生器
   ======================================== */
@media (max-width: 1024px) {
    .call-number-builder .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .input-with-button {
        flex-direction: column;
    }

    .generate-btn,
    .assemble-btn {
        width: 100%;
        justify-content: center;
    }

    .call-number-builder .form-row {
        grid-template-columns: 1fr;
    }
}
/* 編目時間顯示 */
.cataloging-time {
    margin: 0.5rem 0;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 3px solid #0284c7;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    color: #0c4a6e;
}

.cataloging-time strong {
    color: #0369a1;
    font-weight: 600;
}

/* ========================================
   國家圖書館控制詞彙主題詞樣式
   ======================================== */

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

/* 統計資訊 */
.controlled-headings-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stats-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stats-item strong {
    color: var(--primary-color);
}

/* 主題詞列表 */
.controlled-headings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-bottom: 1rem;
}

/* 單一主題詞項目 */
.controlled-heading-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s;
    position: relative;
}

.controlled-heading-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.controlled-heading-item.relevance-high {
    border-left: 3px solid var(--success-color);
}

.controlled-heading-item.relevance-medium {
    border-left: 3px solid var(--warning-color);
}

.controlled-heading-item.relevance-low {
    border-left: 3px solid var(--text-muted);
}

/* 主題詞主要內容 */
.heading-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.heading-term {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.heading-relevance {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.heading-relevance.relevance-high {
    background: #dcfce7;
    color: #166534;
}

.heading-relevance.relevance-medium {
    background: #fef3c7;
    color: #92400e;
}

.heading-relevance.relevance-low {
    background: #f1f5f9;
    color: #64748b;
}

/* 主題詞中繼資訊 */
.heading-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.heading-class {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #e0f2fe;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    color: #0369a1;
}

.heading-source {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.heading-notes,
.heading-related {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.heading-related {
    color: var(--info-color);
}

/* 採用按鈕 */
.add-heading-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
}

.controlled-heading-item:hover .add-heading-btn {
    opacity: 1;
}

.add-heading-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* 搜尋列 */
.headings-search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.headings-search .form-input {
    flex: 1;
}

.search-heading-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.search-heading-btn:hover {
    background: var(--primary-hover);
}

/* 已選擇的主題詞 */
.selected-headings {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.selected-headings label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.controlled-tag {
    background: #e0f2fe !important;
    border: 1px solid #0284c7 !important;
}

.controlled-tag .tag-badge {
    font-size: 0.65rem;
    background: #0284c7;
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 0.2rem;
    margin-left: 0.25rem;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .controlled-headings-stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .headings-search {
        flex-direction: column;
    }

    .search-heading-btn {
        width: 100%;
    }

    .controlled-heading-item .add-heading-btn {
        opacity: 1;
        position: static;
        width: 100%;
        margin-top: 0.5rem;
    }
}
