/* ============================================
   BookPlatform - Reusable Components
   Dark Theme Component Library
   ============================================ */

/* --- Tabs --- */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid #2a2a3a;
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 12px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #888;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  position: relative;
  bottom: -1px;
}

.tab:hover {
  color: #e0e0e0;
}

.tab.active {
  color: #6c5ce7;
  border-bottom-color: #6c5ce7;
}

.tab .tab-count {
  margin-left: 8px;
  background: #2a2a3a;
  color: #888;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.tab.active .tab-count {
  background: rgba(108, 92, 231, 0.15);
  color: #6c5ce7;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  background: transparent;
  color: #888;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-btn:hover {
  border-color: #6c5ce7;
  color: #e0e0e0;
  background: rgba(108, 92, 231, 0.08);
}

.page-btn.active {
  background: #6c5ce7;
  border-color: #6c5ce7;
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.page-btn--prev,
.page-btn--next {
  font-size: 0.78rem;
  padding: 0 14px;
}

.pagination-info {
  font-size: 0.82rem;
  color: #888;
  margin: 0 8px;
}

/* --- Dropdown --- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  background: #12121a;
  color: #e0e0e0;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-trigger:hover {
  border-color: #6c5ce7;
}

.dropdown-trigger .caret {
  font-size: 0.6rem;
  transition: transform 0.2s ease;
}

.dropdown.open .dropdown-trigger .caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #1a1a2e;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu--right {
  left: auto;
  right: 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: #e0e0e0;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: rgba(108, 92, 231, 0.1);
  color: #fff;
}

.dropdown-item--danger {
  color: #ff6b6b;
}

.dropdown-item--danger:hover {
  background: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
}

.dropdown-divider {
  height: 1px;
  background: #2a2a3a;
  margin: 6px 0;
}

/* --- Tooltip --- */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 12px;
  background: #1a1a2e;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #2a2a3a;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 1001;
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tooltip--bottom::after {
  bottom: auto;
  top: calc(100% + 8px);
}

.tooltip--bottom::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #2a2a3a;
}

/* --- Progress Stepper --- */
.progress-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.stepper-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #2a2a3a;
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: #888;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.stepper-step.active .stepper-circle {
  border-color: #6c5ce7;
  background: #6c5ce7;
  color: #fff;
  box-shadow: 0 0 16px rgba(108, 92, 231, 0.3);
}

.stepper-step.completed .stepper-circle {
  border-color: #00c9a7;
  background: #00c9a7;
  color: #fff;
}

.stepper-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #888;
  transition: color 0.2s ease;
}

.stepper-step.active .stepper-label {
  color: #fff;
}

.stepper-step.completed .stepper-label {
  color: #00c9a7;
}

.stepper-line {
  flex: 1;
  height: 2px;
  background: #2a2a3a;
  margin: 0 12px;
  min-width: 40px;
  transition: background 0.3s ease;
}

.stepper-line.completed {
  background: #00c9a7;
}

/* --- Tag / Chip --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #2a2a3a;
  transition: all 0.2s ease;
}

.tag--purple {
  background: rgba(108, 92, 231, 0.12);
  color: #6c5ce7;
  border-color: rgba(108, 92, 231, 0.25);
}

.tag--pink {
  background: rgba(168, 85, 247, 0.12);
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.25);
}

.tag--green {
  background: rgba(0, 201, 167, 0.12);
  color: #00c9a7;
  border-color: rgba(0, 201, 167, 0.25);
}

.tag--blue {
  background: rgba(0, 163, 255, 0.12);
  color: #00a3ff;
  border-color: rgba(0, 163, 255, 0.25);
}

.tag--red {
  background: rgba(255, 107, 107, 0.12);
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.25);
}

.tag--yellow {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
  border-color: rgba(255, 193, 7, 0.25);
}

.tag-close {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.65rem;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

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

/* --- Avatar --- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  background: linear-gradient(135deg, #6c5ce7, #a855f7);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.avatar--md {
  width: 40px;
  height: 40px;
  font-size: 0.9rem;
}

.avatar--lg {
  width: 56px;
  height: 56px;
  font-size: 1.2rem;
}

.avatar--xl {
  width: 80px;
  height: 80px;
  font-size: 1.6rem;
}

.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  border: 2px solid #0a0a0f;
  margin-left: -10px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

.avatar-status {
  position: relative;
}

.avatar-status::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0a0a0f;
  background: #888;
}

.avatar-status--online::after {
  background: #00c9a7;
}

.avatar-status--away::after {
  background: #ffc107;
}

.avatar-status--offline::after {
  background: #555;
}

/* --- Alert --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid #2a2a3a;
  background: #12121a;
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e0e0e0;
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.alert-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.alert-dismiss:hover {
  color: #e0e0e0;
}

.alert-info {
  border-color: rgba(0, 163, 255, 0.25);
  background: rgba(0, 163, 255, 0.06);
}

.alert-info .alert-icon,
.alert-info .alert-title {
  color: #00a3ff;
}

.alert-warning {
  border-color: rgba(255, 193, 7, 0.25);
  background: rgba(255, 193, 7, 0.06);
}

.alert-warning .alert-icon,
.alert-warning .alert-title {
  color: #ffc107;
}

.alert-error {
  border-color: rgba(255, 107, 107, 0.25);
  background: rgba(255, 107, 107, 0.06);
}

.alert-error .alert-icon,
.alert-error .alert-title {
  color: #ff6b6b;
}

.alert-success {
  border-color: rgba(0, 201, 167, 0.25);
  background: rgba(0, 201, 167, 0.06);
}

.alert-success .alert-icon,
.alert-success .alert-title {
  color: #00c9a7;
}

/* --- Collapsible / Accordion --- */
.accordion {
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

.accordion-item {
  border-bottom: 1px solid #2a2a3a;
}

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

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #12121a;
  color: #e0e0e0;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
  width: 100%;
  text-align: left;
}

.accordion-header:hover {
  background: #1a1a2e;
}

.accordion-chevron {
  font-size: 0.7rem;
  color: #888;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion-item.open .accordion-body {
  max-height: 500px;
}

.accordion-content {
  padding: 16px 20px;
  font-size: 0.88rem;
  color: #888;
  line-height: 1.6;
  background: #0a0a0f;
}

/* --- Search Box --- */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #12121a;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 10px 16px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: #6c5ce7;
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

.search-box-icon {
  color: #888;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.search-box input::placeholder {
  color: #555;
}

.search-box-clear {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 2px;
  font-size: 0.85rem;
  transition: color 0.2s ease;
  display: none;
}

.search-box-clear.visible {
  display: block;
}

.search-box-clear:hover {
  color: #e0e0e0;
}

.search-box-kbd {
  font-size: 0.7rem;
  color: #555;
  background: #0a0a0f;
  border: 1px solid #2a2a3a;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- File Upload Area --- */
.file-upload {
  border: 2px dashed #2a2a3a;
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  background: #12121a;
  cursor: pointer;
  transition: all 0.3s ease;
}

.file-upload:hover,
.file-upload.dragover {
  border-color: #6c5ce7;
  background: rgba(108, 92, 231, 0.04);
}

.file-upload-icon {
  font-size: 2.5rem;
  color: #555;
  margin-bottom: 16px;
  transition: color 0.2s ease;
}

.file-upload:hover .file-upload-icon {
  color: #6c5ce7;
}

.file-upload-text {
  font-size: 0.95rem;
  color: #e0e0e0;
  margin-bottom: 6px;
}

.file-upload-text span {
  color: #6c5ce7;
  font-weight: 600;
}

.file-upload-hint {
  font-size: 0.8rem;
  color: #555;
}

.file-upload input[type="file"] {
  display: none;
}

.file-upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #0a0a0f;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  margin-top: 16px;
}

.file-upload-preview-name {
  flex: 1;
  font-size: 0.85rem;
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-preview-size {
  font-size: 0.78rem;
  color: #888;
  flex-shrink: 0;
}

.file-upload-preview-remove {
  background: none;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.file-upload-preview-remove:hover {
  opacity: 0.7;
}

/* --- Word Count Indicator --- */
.word-count {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.word-count-bar {
  flex: 1;
  height: 4px;
  background: #2a2a3a;
  border-radius: 2px;
  overflow: hidden;
}

.word-count-fill {
  height: 100%;
  border-radius: 2px;
  background: #6c5ce7;
  transition: width 0.3s ease, background 0.3s ease;
}

.word-count-fill.warning {
  background: #ffc107;
}

.word-count-fill.danger {
  background: #ff6b6b;
}

.word-count-fill.complete {
  background: #00c9a7;
}

.word-count-text {
  font-size: 0.78rem;
  color: #888;
  white-space: nowrap;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.word-count-text strong {
  color: #e0e0e0;
  font-weight: 600;
}

/* --- AI Provider Badge --- */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid;
}

.ai-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ai-badge--openai {
  background: rgba(0, 163, 86, 0.1);
  border-color: rgba(0, 163, 86, 0.25);
  color: #00a356;
}

.ai-badge--openai .ai-badge-dot {
  background: #00a356;
}

.ai-badge--anthropic {
  background: rgba(204, 147, 79, 0.1);
  border-color: rgba(204, 147, 79, 0.25);
  color: #cc934f;
}

.ai-badge--anthropic .ai-badge-dot {
  background: #cc934f;
}

.ai-badge--gemini {
  background: rgba(66, 133, 244, 0.1);
  border-color: rgba(66, 133, 244, 0.25);
  color: #4285f4;
}

.ai-badge--gemini .ai-badge-dot {
  background: #4285f4;
}

.ai-badge--mistral {
  background: rgba(255, 119, 0, 0.1);
  border-color: rgba(255, 119, 0, 0.25);
  color: #ff7700;
}

.ai-badge--mistral .ai-badge-dot {
  background: #ff7700;
}

.ai-badge--local {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.25);
  color: #a855f7;
}

.ai-badge--local .ai-badge-dot {
  background: #a855f7;
}

.ai-badge--active {
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 transparent;
  }
  50% {
    box-shadow: 0 0 12px rgba(108, 92, 231, 0.15);
  }
}

.ai-badge-model {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.8;
}
