/* Toolbar */
.table-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bg-body);
}

.search-wrapper {
  position: relative;
  flex: 0 1 300px;
}
.search-wrapper svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 11px 7px 32px;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  background: white;
  outline: none;
  color: var(--text-primary);
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--primary); }

/* Data Grid (Spreadsheet) */
.table-wrapper {
  flex: 1;
  overflow: auto; 
  margin: 0;
  border-top: 1px solid var(--border-color);
  position: relative;
  background: white;
}
.data-grid {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 13.5px;
}
.data-grid th, .data-grid td {
  border-bottom: 1px solid var(--bg-subtle);
  border-right: 1px solid var(--bg-subtle);
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
}
.data-grid th {
  background-color: var(--bg-body);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  padding: 12px 16px;
  font-weight: 500;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 4;
}
.data-grid th .th-content {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.data-grid th .icon-box {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Sticky first/second columns */
.data-grid th.sticky-col, .data-grid td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
}
.data-grid th.sticky-col {
  z-index: 6;
  background: var(--bg-body);
}
.data-grid th.sticky-col.email-col, .data-grid td.sticky-col.email-col {
  left: 48px; /* Offset by checkbox width */
  box-shadow: 2px 0 0 rgba(20,23,28,0.02);
  min-width: 260px;
}

.data-grid tbody tr {
  background: white;
  transition: background 0.1s;
}
.data-grid tbody tr:hover {
  background-color: var(--bg-hover);
}

.cell-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badges & Chips */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--success-light);
  color: var(--success);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 6px;
}
.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.chip {
  display: inline-block;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12.5px;
  color: var(--text-primary);
  background: white;
  white-space: nowrap;
}
.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-dark);
  border-radius: 7px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-primary);
  background: white;
  max-width: 200px;
  cursor: pointer;
  transition: all 0.2s;
}
.file-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
}
.file-btn svg { color: var(--primary); flex-shrink: 0; }
.file-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.open-row-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}
.open-row-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Checkbox */
input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Column Popover (Drawer style from new design) */
.column-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,23,28,0.28);
  z-index: 50;
  animation: fadeIn 0.14s ease;
}
.column-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: white;
  z-index: 60;
  box-shadow: -8px 0 40px rgba(20,23,28,0.14);
  display: flex;
  flex-direction: column;
  animation: drawerIn 0.18s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.column-drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color);
}
.column-drawer-header span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.column-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}
.column-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 9px;
  cursor: grab;
}
.column-item:hover { background: var(--bg-hover); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Summary View */
.summary-container {
  flex: 1;
  padding: 32px 40px 80px;
  overflow-y: auto;
  background: #fafafa;
}

/* Question Cards */
.summary-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.summary-card-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.q-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.q-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3effc;
  color: #7c3aed;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}
.q-badge.text-badge { background: #eff6ff; color: #2563eb; }
.q-badge.number-badge { background: #fef9c3; color: #d97706; }

.q-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.q-meta {
  font-size: 13px;
  color: #6b7280;
  margin-left: 2px;
}

/* Card Controls Row */
.card-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  margin-bottom: 24px;
}

.summary-tabs {
  display: inline-flex;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2px;
}

.summary-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: all 0.2s;
}

.summary-tab.active {
  background: #f3f4f6;
  color: #111827;
}

.view-toggles {
  display: inline-flex;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2px;
}

.view-toggle-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.view-toggle-btn.active {
  background: #f3f4f6;
  color: #111827;
}

/* Choice Table */
.choice-table {
  width: 100%;
  border-collapse: collapse;
}

.choice-table th {
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
}

.choice-table td {
  font-size: 14px;
  color: #1f2937;
  padding: 16px;
  border-bottom: 1px solid #f9fafb;
}

.choice-table tr:last-child td {
  border-bottom: none;
}

/* Chart Container */
.chart-container {
  width: 100%;
  height: 350px;
  position: relative;
}

/* Summary body wrapper (contains overview + trends) */
.summary-body-container {
  width: 100%;
}

/* Trends line chart container */
.trends-container {
  padding: 0 4px 8px;
}

.trends-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #9ca3af;
  font-size: 14px;
}

/* Numeric Stats */
.numeric-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-box {
  background: white;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.01);
}

.stat-value {
  font-size: 26px;
  font-weight: 400;
  color: #111827;
  margin-bottom: 8px;
}

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #9ca3af;
}

.stat-label svg {
  color: #d1d5db;
}

/* Text List */
.text-search-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.text-search-wrapper {
  position: relative;
  width: 260px;
}

.text-search-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.text-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

.text-search-input:focus {
  border-color: #3b82f6;
}

.text-results-count {
  font-size: 13.5px;
  color: #6b7280;
  flex: 1;
}

.text-sort-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  color: #6b7280;
  cursor: pointer;
}

.text-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.text-list-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
  background: white;
}

.text-list-quote {
  color: #d1d5db;
  font-size: 20px;
  font-family: Georgia, serif;
  line-height: 1;
  margin-top: -2px;
}

.text-list-val {
  flex: 1;
  font-size: 14px;
  color: #111827;
  line-height: 1.5;
}

.text-list-date {
  font-size: 13px;
  color: #9ca3af;
  white-space: nowrap;
}

/* Detail Drawer */
.detail-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,23,28,0.28);
  z-index: 50;
}
.detail-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 92vw;
  background: white;
  z-index: 60;
  box-shadow: -8px 0 40px rgba(20,23,28,0.14);
  display: flex;
  flex-direction: column;
}
.detail-drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}
.detail-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 40px;
  background: var(--bg-body);
}
.detail-card {
  background: white;
  border: 1px solid #eceef0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.detail-card-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.detail-card-value {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-content {
  background: white;
  border-radius: 12px;
  width: 90vw;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}
.modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
}
.modal-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Filter Popover */
.filter-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 340px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  padding: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-select {
  flex: 1;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: white;
  outline: none;
  cursor: pointer;
}
.filter-select:focus {
  border-color: var(--primary);
}
.filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
