/* Knowledge Base Admin Page Styles */

/* Content Header */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.content-header-left {
  flex: 1;
}

.content-subtitle {
  font-size: 14px;
  color: #6B7280;
  margin: 0;
  line-height: 1.5;
}

.content-header-right {
  flex-shrink: 0;
}

/* Search Filter Bar */
.search-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 44px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  font-size: 14px;
  background: #F9FAFB;
  color: #111827;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #0D9488;
  background: white;
}

.search-input::placeholder {
  color: #9CA3AF;
}

.filter-buttons {
  display: flex;
  gap: 12px;
}

.filter-select {
  padding: 10px 14px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  font-size: 14px;
  background: #F9FAFB;
  color: #374151;
  cursor: pointer;
  min-width: 180px;
}

.filter-select:focus {
  outline: none;
  border-color: #0D9488;
}

/* Table Container */
.table-container {
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: #F9FAFB;
}

.data-table th {
  padding: 14px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #E5E7EB;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: #0D9488;
}

.data-table th .sort-icon {
  margin-left: 6px;
  opacity: 0.5;
  vertical-align: middle;
}

.data-table th.actions-col {
  width: 120px;
  text-align: right;
}

.data-table tbody tr {
  border-bottom: 1px solid #F3F4F6;
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: #F9FAFB;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table td {
  padding: 16px 20px;
  font-size: 14px;
  color: #374151;
}

.file-name-cell {
  font-weight: 500;
  color: #111827;
}

/* Category Tags */
.category-tag {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.category-tag.cardio {
  background: #DBEAFE;
  color: #1D4ED8;
}

.category-tag.hormonal {
  background: #FEE2E2;
  color: #B91C1C;
}

.category-tag.longevity {
  background: #FEF3C7;
  color: #B45309;
}

.category-tag.immune {
  background: #D1FAE5;
  color: #047857;
}

.category-tag.gut {
  background: #CCFBF1;
  color: #0D9488;
}

.category-tag.general {
  background: #F3F4F6;
  color: #4B5563;
}

.notes-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6B7280;
  font-size: 13px;
}

.actions-cell {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.action-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #9CA3AF;
}

.action-btn:hover {
  background: #F3F4F6;
}

.action-btn.view:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
}

.action-btn.edit:hover {
  background: rgba(245, 158, 11, 0.1);
  color: #F59E0B;
}

.action-btn.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #F3F4F6;
  color: #374151;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #E5E7EB;
  background: #F9FAFB;
  border-radius: 0 0 16px 16px;
}

/* Form Styles */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.required {
  color: #EF4444;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  color: #111827;
  font-family: inherit;
  transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #0D9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* File Upload Zone */
.file-upload-zone {
  position: relative;
  border: 2px dashed #E5E7EB;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  background: #F9FAFB;
  transition: all 0.2s;
  cursor: pointer;
}

.file-upload-zone:hover {
  border-color: #0D9488;
  background: rgba(13, 148, 136, 0.02);
}

/* File input is hidden via display:none in HTML, managed by JS */

.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-text {
  font-size: 14px;
  color: #374151;
  margin: 0;
  font-weight: 500;
}

.upload-hint {
  font-size: 12px;
  color: #9CA3AF;
  margin: 0;
}

/* File Preview List */
.file-preview-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(13, 148, 136, 0.08);
  border-radius: 8px;
}

.file-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: #6B7280;
}

.file-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-remove:hover {
  background: rgba(239, 68, 68, 0.2);
}
/* Per-file upload status indicator */
.file-preview-item .file-upload-status {
  font-size: 14px;
  min-width: 20px;
  text-align: center;
  color: #6B7280;
  flex-shrink: 0;
}

/* Upload success/error states */
.file-preview-item.upload-success {
  background: rgba(16, 185, 129, 0.08) !important;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.file-preview-item.upload-error {
  background: rgba(239, 68, 68, 0.06) !important;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Add more files link */
.file-preview-list .add-more-files {
  padding: 10px;
  text-align: center;
  color: #0D9488;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px dashed #D1D5DB;
  border-radius: 8px;
  transition: all 0.2s;
}

.file-preview-list .add-more-files:hover {
  background: rgba(13, 148, 136, 0.04);
  border-color: #0D9488;
}

/* Drag-over state for upload zone */
.file-upload-zone.drag-over {
  border-color: #0D9488 !important;
  background: rgba(13, 148, 136, 0.04) !important;
}

/* Btn spinner for upload status */
.file-upload-status .btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(13, 148, 136, 0.3);
  border-top-color: #0D9488;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.file-remove:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #E5E7EB;
  border-top-color: #0D9488;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.loading-state p {
  color: #6B7280;
  font-size: 14px;
  margin: 0;
}

/* Empty State Card */
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  background: white;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
}

.empty-state-card .empty-icon {
  margin-bottom: 16px;
  opacity: 0.8;
}

.empty-state-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 8px 0;
}

.empty-state-card p {
  font-size: 14px;
  color: #6B7280;
  margin: 0 0 24px 0;
  max-width: 320px;
}

/* Detail Grid (for view modal) */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.detail-item label {
  font-size: 12px;
  font-weight: 500;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-item p {
  font-size: 14px;
  color: #111827;
  margin: 0;
}

/* Upload Button - Enhanced Styling */
.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #0D9488 0%, #0F766E 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
  position: relative;
  overflow: hidden;
}

.btn-upload::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-upload:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.45);
  background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
}

.btn-upload:hover::before {
  opacity: 1;
}

.btn-upload:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.btn-upload svg {
  transition: transform 0.3s;
}

.btn-upload:hover svg {
  transform: rotate(90deg);
}

.btn-upload .btn-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 3px;
}

/* Responsive */
@media (max-width: 768px) {
  .search-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrapper {
    max-width: none;
  }

  .filter-buttons {
    justify-content: stretch;
  }

  .filter-select {
    flex: 1;
  }

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

  .data-table th,
  .data-table td {
    padding: 12px 14px;
  }

  .notes-cell {
    max-width: 150px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .modal-dialog {
    width: 95%;
    margin: 20px;
  }

  .content-header {
    flex-direction: column;
    gap: 16px;
  }
}

/* Upload Progress Bar */
.upload-progress-container {
  margin-top: 20px;
  padding: 16px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
}

.upload-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.upload-progress-header span {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

#uploadProgressPercent {
  font-weight: 600;
  color: #0F766E;
}

.upload-progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: #E5E7EB;
  border-radius: 4px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0F766E 0%, #14B8A6 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.upload-progress-detail {
  margin-top: 8px;
  font-size: 12px;
  color: #6B7280;
}

/* Progress bar animation for indeterminate state */
.upload-progress-bar.indeterminate {
  width: 30% !important;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(200%);
  }
  100% {
    transform: translateX(-100%);
  }
}
