/* Configuration & Admin Page Styles */

.admin-page {
  padding: 1rem 1.5rem 1.5rem;
  line-height: 1.25;
}

.admin-page h2 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.2;
}

.config-section {
  background: white;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1rem;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
}

.config-section h3 {
  margin-top: 0;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  max-width: 800px;
  margin: 0 auto;
}

/* On desktop, still show a bit wider if possible, but keep it centered */
@media (min-width: 1024px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
    max-width: 750px;
  }
}

.admin-page .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  align-items: end;
}

.config-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.config-step {
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  overflow: hidden;
}

.config-step-header {
  width: 100%;
  border: none;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  text-align: left;
}

.config-step-header:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.4);
  outline-offset: 2px;
}

.step-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-number {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #1f2937;
}

.step-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #0f172a;
}

.step-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.step-subtitle--completed {
  color: #166534;
  font-weight: 600;
}

.step-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.step-status--completed {
  background: #dcfce7;
  color: #166534;
}

.step-status--failed {
  background: #fee2e2;
  color: #991b1b;
}

.step-status--processing {
  background: #fef3c7;
  color: #92400e;
}

.step-status--locked {
  background: #e2e8f0;
  color: #64748b;
}

.step-toggle-icon {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
  color: #64748b;
}

.config-step-header[aria-expanded="false"] .step-toggle-icon {
  transform: rotate(-90deg);
}

.config-step-header[aria-expanded="false"] + .config-step-body {
  display: none;
}

.nav-locked a {
  pointer-events: none;
}

.config-step-body {
  padding: 1.1rem 1.5rem 1.35rem;
}

.config-step.locked .config-step-body {
  opacity: 0.6;
  pointer-events: none;
}

.config-step.locked .config-step-header {
  cursor: not-allowed;
}

.step-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.config-complete {
  margin-top: 1.25rem;
  padding: 1.5rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  display: flex;
  align-items: center;
  gap: 16px;
}

.config-complete-icon {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: #22c55e;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  animation: pop 0.6s ease;
}

.config-complete-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #166534;
}

.config-complete-message {
  font-size: 0.9rem;
  color: #166534;
  margin: 6px 0 12px;
}

@keyframes pop {
  0% {
    transform: scale(0.9);
    opacity: 0.6;
  }
  60% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 600px) {
  .config-complete {
    flex-direction: column;
    align-items: flex-start;
  }
}

.config-notice {
  margin: 0 auto 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid rgba(234, 179, 8, 0.5);
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 800px;
}
.config-notice.success {
  background: #dcfce7;
  color: #166534;
  border-color: rgba(34, 197, 94, 0.4);
}

.drive-auth-block {
  padding: 8px;
  background: #f1f5f9;
  border-radius: 10px;
}
.drive-auth-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.drive-auth-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}
.status-inline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .admin-page {
    padding: 0.75rem 1rem 1rem;
  }
  .config-section {
    padding: 1rem;
  }
  .admin-grid {
    gap: 0.75rem;
  }
}

/* Folder Selection Display */
.selected-folder-display {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 12px;
  margin-bottom: 12px;
}
.selected-files-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.folder-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}
.selected-folder-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  color: #166534;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 100px;
}
.folder-display-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .folder-display-actions {
    width: 100%;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(34, 197, 94, 0.2);
    justify-content: flex-end;
  }
}
.action-divider {
  color: #cbd5e1;
  font-size: 0.8rem;
  user-select: none;
}
.folder-picker-actions {
  display: flex;
  gap: 10px;
}

/* Selected Files List */
.selected-files-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 0 0;
  border-top: 1px solid rgba(34, 197, 94, 0.3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}
.selected-files-list li {
  font-size: 0.85rem;
  color: #166534;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.selected-files-list li::before {
  content: "📄";
  font-size: 0.75rem;
}

/* Indexing Progress Indicator */
.indexing-status-inline {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
}
.indexing-inline-text {
  font-weight: 600;
  font-size: 0.85rem;
}

.indexing-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
  width: 100%;
}
.indexing-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
  border-radius: 999px;
  transition: width 0.3s ease-out;
  position: relative;
  overflow: hidden;
}
.indexing-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .folder-picker-actions {
    flex-direction: column;
  }
  .folder-picker-actions button {
    width: 100%;
  }
  .drive-auth-row {
    flex-direction: column;
    align-items: stretch;
  }
  .drive-auth-row button {
    width: 100%;
  }
  #openai-test-result {
    display: block;
    margin-left: 0 !important;
    margin-top: 8px;
  }
}
