/* =========================================================
   Internal Database Search — Styles
   ========================================================= */

:root {
  --ctf-navy:    #1b2a4a;
  --ctf-blue:    #2d5f8a;
  --ctf-gold:    #b8952e;
  --ctf-light:   #f5f6f8;
  --ctf-border:  #dce0e5;
  --ctf-danger:  #dc3545;
  --ctf-success: #198754;
  --ctf-text:    #2c3e50;
  --ctf-muted:   #6c757d;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--ctf-light);
  color: var(--ctf-text);
  margin: 0;
  min-height: 100vh;
}

/* Navbar */
.ctf-navbar {
  background: var(--ctf-navy);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}
.ctf-navbar-brand {
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
}
.ctf-navbar-brand:hover { color: var(--ctf-gold); }
.ctf-navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ctf-navbar-user { color: #ccc; font-size: 0.9rem; }
.ctf-navbar .btn-outline-light { font-size: 0.85rem; padding: 0.25rem 0.75rem; }

/* Auth pages */
.ctf-auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 2rem;
}
.ctf-auth-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}
.ctf-auth-card h2 {
  text-align: center;
  margin-bottom: 0.25rem;
  color: var(--ctf-navy);
  font-size: 1.5rem;
}
.ctf-auth-card .ctf-subtitle {
  text-align: center;
  color: var(--ctf-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Main content */
.ctf-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Cards */
.ctf-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid var(--ctf-border);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.ctf-card h3 {
  margin-top: 0;
  font-size: 1.1rem;
  color: var(--ctf-navy);
  margin-bottom: 1rem;
}

/* Question form */
.ctf-question-area {
  width: 100%;
  border: 2px solid var(--ctf-border);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 1rem;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.ctf-question-area:focus {
  outline: none;
  border-color: var(--ctf-blue);
}
.ctf-question-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}
.ctf-section-select {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ctf-border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: #fff;
}

/* Buttons */
.ctf-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.ctf-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.ctf-btn-primary {
  background: var(--ctf-blue);
  color: #fff;
}
.ctf-btn-primary:hover:not(:disabled) { background: var(--ctf-navy); }
.ctf-btn-danger {
  background: var(--ctf-danger);
  color: #fff;
}
.ctf-btn-danger:hover:not(:disabled) { background: #b02a37; }
.ctf-btn-sm { font-size: 0.8rem; padding: 0.25rem 0.6rem; }

/* Answer area */
.ctf-answer {
  line-height: 1.7;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

/* Citations */
.ctf-citations {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ctf-border);
}
.ctf-citations h4 {
  font-size: 0.9rem;
  color: var(--ctf-muted);
  margin-bottom: 0.75rem;
}
.ctf-citation-item {
  padding: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--ctf-text);
  border-bottom: 1px solid #f0f0f0;
}
.ctf-citation-item:last-child { border-bottom: none; }
.ctf-citation-num {
  font-weight: 600;
  color: var(--ctf-blue);
  margin-right: 0.5rem;
}
.ctf-citation-section {
  color: var(--ctf-gold);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Inline citation links [N] in answer text */
.ctf-inline-cite {
  color: var(--ctf-blue);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.ctf-inline-cite:hover {
  text-decoration: underline;
}

/* Citation highlight flash on scroll-to */
.ctf-citation-highlight {
  background: rgba(52, 144, 220, 0.12);
  border-radius: 4px;
  transition: background 0.8s ease;
}

/* PDF link in citations */
.ctf-citation-pdf {
  color: var(--ctf-blue);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  margin-left: 0.5rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.ctf-citation-pdf:hover {
  opacity: 1;
  text-decoration: underline;
}

/* File links in admin table */
.ctf-file-link {
  color: var(--ctf-blue);
  text-decoration: none;
  cursor: pointer;
}
.ctf-file-link:hover {
  color: var(--ctf-navy);
  text-decoration: underline;
}

/* Loading spinner */
.ctf-loading {
  text-align: center;
  padding: 2rem;
  color: var(--ctf-muted);
}
.ctf-spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--ctf-border);
  border-top-color: var(--ctf-blue);
  border-radius: 50%;
  animation: ctfSpin 0.8s linear infinite;
}
@keyframes ctfSpin { to { transform: rotate(360deg); } }
.ctf-loading-note {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}

/* Recent queries */
.ctf-recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ctf-recent-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ctf-blue);
}
.ctf-recent-item:hover { color: var(--ctf-navy); }
.ctf-recent-item:last-child { border-bottom: none; }
.ctf-recent-date {
  font-size: 0.75rem;
  color: var(--ctf-muted);
  margin-left: 0.5rem;
}

/* Admin tabs */
.ctf-tabs {
  display: flex;
  border-bottom: 2px solid var(--ctf-border);
  margin-bottom: 1.5rem;
  gap: 0;
}
.ctf-tab {
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--ctf-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.ctf-tab:hover { color: var(--ctf-text); }
.ctf-tab.active {
  color: var(--ctf-blue);
  border-bottom-color: var(--ctf-blue);
  font-weight: 500;
}
.ctf-tab-content { display: none; }
.ctf-tab-content.active { display: block; }

/* Budget bar */
.ctf-budget-bar-wrapper {
  background: #e9ecef;
  border-radius: 6px;
  height: 24px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.ctf-budget-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  min-width: 2rem;
}
.ctf-budget-bar.green { background: var(--ctf-success); }
.ctf-budget-bar.yellow { background: #ffc107; color: #333; }
.ctf-budget-bar.red { background: var(--ctf-danger); }

/* Tables */
.ctf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.ctf-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--ctf-border);
  color: var(--ctf-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ctf-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

/* Alerts */
.ctf-alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}
.ctf-alert-success {
  background: #d1e7dd;
  color: #0a5032;
  border: 1px solid #badbcc;
}
.ctf-alert-danger {
  background: #f8d7da;
  color: #842029;
  border: 1px solid #f5c2c7;
}
.ctf-alert-info {
  background: #cff4fc;
  color: #055160;
  border: 1px solid #b6effb;
}

/* Credential box */
.ctf-credential-box {
  background: #f8f9fa;
  border: 1px solid var(--ctf-border);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.ctf-credential-box strong { color: var(--ctf-navy); }
.ctf-credential-box code {
  background: #e9ecef;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.95em;
}

/* Stat cards */
.ctf-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.ctf-stat-item {
  text-align: center;
}
.ctf-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ctf-navy);
}
.ctf-stat-label {
  font-size: 0.8rem;
  color: var(--ctf-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Responsive */
@media (max-width: 600px) {
  .ctf-container { padding: 0 1rem; }
  .ctf-question-controls { flex-direction: column; align-items: stretch; }
  .ctf-stat-grid { grid-template-columns: 1fr 1fr; }
  .ctf-navbar { padding: 0.5rem 1rem; }
}
