/**
 * Documents Page Styles - 文件管理頁面樣式
 * 
 * 包含:
 * - 分類過濾器
 * - 文件卡片網格
 * - PDF 預覽模態框
 * - 檔案類型圖示
 * - 響應式設計
 */

/* ==================== 文件容器 ==================== */

.documents-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.page-title {
  font-size: 2rem;
  color: var(--text-primary);
  margin-bottom: 2rem;
  text-align: center;
}

/* ==================== 分類過濾器 ==================== */

.category-filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.category-filter-btn {
  padding: 0.5rem 1.25rem;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.category-filter-btn:hover {
  background: var(--bg-highlight);
  border-color: var(--primary-color);
}

.category-filter-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* ==================== 文件網格 ==================== */

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

/* ==================== 文件卡片 ==================== */

.document-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.document-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.document-icon {
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: var(--bg-highlight);
}

/* 檔案類型顏色 */
.document-icon.pdf {
  background: #ff6b6b33;
}

.document-icon.doc,
.document-icon.docx {
  background: #4ecdc433;
}

.document-icon.xls,
.document-icon.xlsx {
  background: #95e1d333;
}

.document-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.document-title {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.document-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.document-category {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-weight: 500;
}

.document-type {
  background: var(--secondary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-weight: 600;
}

.file-size {
  color: var(--text-secondary);
  padding: 0.25rem 0;
}

.document-description {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
  flex: 1;
}

.document-uploader,
.document-upload-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* 文件標籤 */
.document-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.document-tags .tag {
  background: var(--bg-highlight);
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
}

/* ==================== 文件操作按鈕 ==================== */

.document-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.btn-preview-pdf,
.btn-download {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
}

.btn-preview-pdf {
  background: var(--primary-color);
  color: white;
}

.btn-preview-pdf:hover {
  background: var(--primary-hover);
}

.btn-download {
  background: var(--secondary-color);
  color: white;
}

.btn-download:hover {
  background: var(--secondary-hover);
}

/* ==================== PDF 預覽模態框 ==================== */

.pdf-preview-container {
  max-width: 1000px;
  margin: 0 auto;
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 12px 12px 0 0;
}

.pdf-header h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0;
}

.btn-close-pdf {
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
}

.btn-close-pdf:hover {
  color: var(--danger-color);
}

.pdf-loading,
.pdf-error {
  padding: 3rem;
  text-align: center;
  color: var(--text-secondary);
}

.pdf-error {
  color: var(--danger-color);
}

.pdf-iframe {
  width: 100%;
  height: 70vh;
  border: none;
  background: white;
}

.pdf-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 0 0 12px 12px;
  text-align: center;
}

.btn-download-pdf {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  background: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.btn-download-pdf:hover {
  background: var(--primary-hover);
}

/* ==================== 搜尋結果 ==================== */

.search-results-container h3 {
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.search-result-item {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.result-type-badge,
.result-category,
.result-file-type {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.result-type-badge {
  background: var(--primary-color);
  color: white;
}

.result-category {
  background: var(--bg-highlight);
  color: var(--text-primary);
}

.result-file-type {
  background: var(--secondary-color);
  color: white;
}

.result-date {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-left: auto;
}

.result-title {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.result-snippet {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

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

.btn-preview-result,
.btn-download-result {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
}

.btn-preview-result {
  background: var(--primary-color);
  color: white;
}

.btn-preview-result:hover {
  background: var(--primary-hover);
}

.btn-download-result {
  background: var(--secondary-color);
  color: white;
}

.btn-download-result:hover {
  background: var(--secondary-hover);
}

/* ==================== 響應式設計 ==================== */

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

  .category-filters {
    padding: 0.75rem;
  }

  .category-filter-btn {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
  }

  .pdf-preview-container {
    max-height: 95vh;
  }

  .pdf-iframe {
    height: 60vh;
  }

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

  .btn-preview-pdf,
  .btn-download {
    width: 100%;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .document-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==================== Print 樣式 ==================== */

@media print {
  .main-header,
  .main-footer,
  .search-section,
  .category-filters,
  .document-actions,
  .btn-close-pdf {
    display: none;
  }

  .document-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .document-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
