/* ================================================================
   ClerkCheck — Citation Page Styles
   Upload zone, options panel, generate button, result card,
   feedback, metadata, sidebar, history
   ================================================================ */

/* ── App Grid ──────────────────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-lg);
  align-items: start;
  padding-bottom: var(--space-3xl);
  animation: fadeUp 0.6s var(--ease-out) 0.1s both;
}

.workflow {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ── Upload Zone ───────────────────────────────────────────────── */
.upload-card {
  overflow: hidden;
}

.upload-zone {
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  margin: var(--space-md);
  transition:
    border-color var(--duration) var(--ease-out),
    background var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out);
  outline: none;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--gold-400);
  background: var(--gold-50);
}

.upload-zone:focus-visible {
  box-shadow: var(--shadow-gold);
}

.upload-zone.drag-over {
  border-color: var(--gold-500);
  border-style: solid;
  background: var(--gold-50);
  box-shadow: var(--shadow-gold);
}

.upload-zone.has-file {
  border-style: solid;
  border-color: var(--border-strong);
  padding: var(--space-lg);
}

.upload-icon {
  color: var(--navy-700);
  margin: 0 auto var(--space-md);
  transition: transform 0.3s var(--ease-out);
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  transform: translateY(-3px);
}

.upload-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--navy-800);
  margin-bottom: var(--space-xs);
}

.upload-sub {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: var(--space-sm);
}

.upload-browse {
  color: var(--gold-600);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(184, 146, 62, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--duration);
}

.upload-browse:hover {
  text-decoration-color: var(--gold-500);
}

.upload-hint {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

/* File selected state */
.upload-selected {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-align: left;
}

.file-badge {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--gold-50);
  border: 1px solid var(--gold-200);
  border-radius: var(--radius-sm);
  color: var(--gold-600);
}

.file-meta {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

.file-remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: color var(--duration), background var(--duration);
}

.file-remove:hover {
  color: var(--red-600);
  background: var(--red-100);
}

/* ── Options Panel ─────────────────────────────────────────────── */
.options-card {
  overflow: hidden;
}

.options-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: color var(--duration);
}

.options-toggle:hover {
  color: var(--text-1);
}

.chevron-icon {
  transition: transform 0.3s var(--ease-out);
}

.options-toggle[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

.options-body {
  padding: 0 var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ── Controls Row ──────────────────────────────────────────────── */
.controls-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.style-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.style-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.style-toggle {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.style-opt {
  position: relative;
  z-index: 1;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: 4px;
  transition: color var(--duration);
}

.style-opt.active {
  color: var(--navy-900);
}

.style-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--gold-100);
  border: 1px solid var(--gold-200);
  border-radius: 4px;
  transition: transform 0.3s var(--ease-out);
}

.style-toggle[data-active="california"] .style-slider {
  transform: translateX(100%);
}

/* ── Generate Button ───────────────────────────────────────────── */
.btn-generate {
  flex: 1;
  min-width: 180px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--navy-800);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition:
    background var(--duration),
    box-shadow var(--duration),
    opacity var(--duration),
    transform 0.1s;
}

.btn-generate:hover:not(:disabled) {
  background: var(--navy-700);
  box-shadow: var(--shadow-md);
}

.btn-generate:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-generate.loading {
  opacity: 0.85;
  cursor: wait;
}

.btn-loader {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Dot pulse loader */
.dot-pulse {
  display: inline-flex;
  gap: 4px;
}

.dot-pulse::before,
.dot-pulse::after,
.dot-pulse span {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  animation: dotPulse 1.2s ease-in-out infinite;
}

.dot-pulse::before { animation-delay: 0s; }
.dot-pulse span    { animation-delay: 0.15s; }
.dot-pulse::after  { animation-delay: 0.3s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Result Card ───────────────────────────────────────────────── */
.result-card {
  border-left: 3px solid var(--gold-500);
  animation: slideIn 0.4s var(--ease-out);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.form-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-700);
  background: var(--gold-100);
  border: 1px solid var(--gold-200);
  border-radius: 999px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.form-select {
  height: 32px;
  padding: 0 var(--space-sm);
  padding-right: 28px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%238a8a85' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--duration);
}

.form-select:focus {
  outline: none;
  border-color: var(--gold-400);
  box-shadow: var(--shadow-gold);
}

/* Citation Display */
.citation-display {
  padding: var(--space-lg);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--navy-900);
  border: none;
  margin: 0;
  user-select: text;
}

.citation-display i {
  font-style: italic;
}

/* Feedback Row */
.feedback-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--border);
}

.feedback-prompt {
  font-size: 13px;
  color: var(--text-3);
}

.feedback-buttons {
  display: flex;
  gap: 4px;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: color var(--duration), background var(--duration);
}

.feedback-btn:hover {
  background: var(--bg-warm);
  color: var(--text-1);
}

.feedback-btn.selected {
  color: var(--gold-600);
  background: var(--gold-50);
}

.feedback-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.feedback-thanks {
  font-size: 13px;
  color: var(--green-600);
  animation: fadeUp 0.3s var(--ease-out);
}

.feedback-comment-row {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-sm);
  animation: fadeUp 0.3s var(--ease-out);
}

.feedback-textarea {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  transition: border-color var(--duration), box-shadow var(--duration);
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--gold-400);
  box-shadow: var(--shadow-gold);
}

.feedback-textarea::placeholder {
  color: var(--text-3);
}

.feedback-submit {
  align-self: flex-end;
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--navy-800);
  border-radius: var(--radius-sm);
  transition: background var(--duration);
}

.feedback-submit:hover {
  background: var(--navy-700);
}

.feedback-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Metadata Details */
.meta-details {
  border-top: 1px solid var(--border);
}

.meta-details summary {
  padding: var(--space-md) var(--space-lg);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: color var(--duration);
}

.meta-details summary:hover {
  color: var(--text-2);
}

.meta-details[open] summary {
  border-bottom: 1px solid var(--border);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-sm) var(--space-lg);
  padding: var(--space-md) var(--space-lg);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.meta-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.meta-value {
  font-size: 14px;
  color: var(--text-1);
  word-break: break-word;
}

.meta-value .ai-tag {
  display: inline-flex;
  align-items: center;
  height: 15px;
  padding: 0 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--gold-600);
  background: var(--gold-100);
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: calc(3px + 56px + var(--space-lg));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeUp 0.6s var(--ease-out) 0.2s both;
  z-index: 1;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--navy-800);
}

.sidebar-clear {
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--duration), background var(--duration);
}

.sidebar-clear:hover {
  color: var(--red-600);
  background: var(--red-100);
}

.history-list {
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.history-item {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration);
}

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

.history-item:hover {
  background: var(--surface-hover);
}

.history-item.active {
  background: var(--gold-50);
  border-left: 2px solid var(--gold-500);
  padding-left: calc(var(--space-lg) - 2px);
}

.history-citation {
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-citation i { font-style: italic; }

.history-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  font-size: 11px;
  color: var(--text-3);
}

.history-kind {
  text-transform: capitalize;
}

.history-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
}

/* ── Responsive (citation) ─────────────────────────────────────── */
@media (max-width: 900px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .history-list {
    max-height: 300px;
  }
}

@media (max-width: 600px) {
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .style-group {
    justify-content: center;
  }

  .btn-generate {
    width: 100%;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .citation-display {
    font-size: 16px;
    padding: var(--space-md);
  }

  .upload-zone {
    padding: var(--space-xl) var(--space-md);
    margin: var(--space-sm);
  }

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

/* Scrollbar styling */
.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}
