/**
 * Opensolr Search analytics dashboard styles.
 *
 * All classes prefixed with "osa-" (opensolr analytics) to avoid
 * conflicts with Drupal admin theme styles.
 */

/* ============================================================
   WRAPPER
   ============================================================ */
.opensolr-analytics-wrap {
  max-width: 1200px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================================================
   EMBEDDABLE MODE NOTICE
   ============================================================ */
.osa-embed-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
  color: #92400e;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
}

.osa-embed-notice svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.osa-embed-notice a {
  color: #667eea;
  font-weight: 600;
  text-decoration: none;
}

.osa-embed-notice a:hover {
  text-decoration: underline;
}

/* ============================================================
   TIME RANGE BAR
   ============================================================ */
.osa-range-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.osa-range-btn {
  display: inline-block;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.osa-range-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.osa-range-active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

/* ============================================================
   OVERVIEW CARDS
   ============================================================ */
.osa-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.osa-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
}

.osa-card-value {
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.osa-card-label {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ============================================================
   SECTIONS
   ============================================================ */
.osa-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.osa-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   TWO-COLUMN GRID
   ============================================================ */
.osa-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .osa-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   TAB BAR (Table / Chart toggle per section)
   ============================================================ */
.osa-tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 0;
}

.osa-tab {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
}

.osa-tab:hover {
  color: #334155;
}

.osa-tab-active {
  color: #667eea;
  border-bottom-color: #667eea;
}

/* ============================================================
   PDF DOWNLOAD BUTTON (in tab bar, right-aligned)
   ============================================================ */
.osa-pdf-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #667eea;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.osa-pdf-btn:hover {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

.osa-pdf-btn svg {
  flex-shrink: 0;
}

/* ============================================================
   SEARCH INPUT (above each table)
   ============================================================ */
.osa-search {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 10px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.osa-search:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.12);
}

/* ============================================================
   SCROLLABLE TABLE CONTAINER (max-height with overflow)
   ============================================================ */
.osa-table-scroll {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
}

/* ============================================================
   TABLES
   ============================================================ */
.osa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.osa-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border-bottom: 2px solid #f1f5f9;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  user-select: none;
}

/* Sort arrow indicators */
.osa-sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 9px;
  color: #cbd5e1;
  vertical-align: middle;
}

.osa-sort-arrow::after {
  content: '\25B2\25BC';
  letter-spacing: -2px;
}

/* Active sort direction — highlight the relevant arrow */
.osa-sort-asc .osa-sort-arrow::after {
  content: '\25B2';
  color: #667eea;
  letter-spacing: 0;
}

.osa-sort-desc .osa-sort-arrow::after {
  content: '\25BC';
  color: #667eea;
  letter-spacing: 0;
}

.osa-table thead th:hover {
  color: #334155;
}

.osa-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f8fafc;
  color: #334155;
  vertical-align: middle;
}

.osa-table tbody tr:hover {
  background: #f8fafc;
}

.osa-query-cell {
  font-weight: 600;
  color: #1e293b;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.osa-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.osa-page-info {
  font-size: 12px;
  color: #94a3b8;
  margin-right: 8px;
}

.osa-page-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s;
}

.osa-page-btn:hover:not(.osa-page-disabled) {
  background: #e2e8f0;
  color: #1e293b;
}

.osa-page-active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

.osa-page-disabled {
  opacity: 0.4;
  cursor: default;
}

/* ============================================================
   BADGES
   ============================================================ */
.osa-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
}

.osa-badge-red {
  background: #fee2e2;
  color: #dc2626;
}

/* ============================================================
   CTR BAR (inline progress bar in table cells)
   ============================================================ */
.osa-ctr-bar {
  display: inline-block;
  position: relative;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #166534;
  background: linear-gradient(to right, #dcfce7 var(--ctr-width, 0%), #f8fafc var(--ctr-width, 0%));
  border-radius: 4px;
  min-width: 50px;
  text-align: right;
}

/* ============================================================
   RESULT LINK (in top clicks table)
   ============================================================ */
.osa-result-link {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}

.osa-result-link:hover {
  text-decoration: underline;
}

/* ============================================================
   CHARTS
   ============================================================ */
.osa-chart-wrap {
  position: relative;
  height: 200px;
  width: 100%;
}

/* Smaller chart wrap for per-section bar charts */
.osa-chart-wrap-sm {
  height: 360px;
}

.osa-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.osa-empty {
  text-align: center;
  color: #94a3b8;
  padding: 24px 16px;
  font-size: 14px;
}

/* ============================================================
   ELEVATION TABLE (on the elevation form page)
   ============================================================ */
.opensolr-elevation-table {
  font-size: 13px;
}

.opensolr-elevation-table th {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
