/* =========================
     CSS VARIABLES & RESET
  ========================= */
:root {
  --primary-blue: #2563eb;
  --secondary-purple: #7c3aed;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-cyan: #06b6d4;

  --neutral-50: #f8f7ff;
  --neutral-100: #f3f0ff;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;

  /* AI-specific colors */
  --ai-primary: #3b82f6;
  --ai-secondary: #6366f1;
  --ai-success: #10b981;
  --ai-warning: #f59e0b;
  --ai-danger: #ef4444;
  --ai-info: #06b6d4;
  --ai-urgent: #dc2626;
  --ai-high: #f59e0b;
  --ai-medium: #10b981;
  --ai-low: #6b7280;

  --gradient-primary: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--secondary-purple) 100%
  );
  --gradient-background: linear-gradient(
    135deg,
    var(--neutral-50) 0%,
    var(--neutral-100) 100%
  );

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 20px;

  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  --z-dropdown: 1000;
  --z-modal: 1050;
  --z-tooltip: 1060;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--gradient-background);
  color: var(--neutral-800);
  line-height: 1.6;
  font-size: 14px;
  overflow-x: hidden;
}

/* =========================
     LAYOUT COMPONENTS
  ========================= */

.page-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--neutral-200);
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--neutral-200);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--neutral-800);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: bold;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--neutral-800);
}

.nav-section {
  padding: 16px 0;
}

.nav-section:not(:last-child) {
  border-bottom: 1px solid var(--neutral-200);
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 20px 12px;
}

.nav-menu {
  list-style: none;
}

.nav-item {
  margin: 2px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--neutral-700);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background: var(--neutral-100);
  color: var(--primary-blue);
  transform: translateX(2px);
}

.nav-link.active {
  background: var(--primary-blue);
  color: white;
  box-shadow: var(--shadow-md);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-text {
  font-weight: 500;
  font-size: 13px;
}

.nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.nav-badge.success {
  background: var(--accent-emerald);
  color: white;
}

.nav-badge.info {
  background: var(--primary-blue);
  color: white;
}

.nav-badge.warning {
  background: var(--accent-amber);
  color: white;
}

.main-wrapper {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
  background: var(--gradient-background);
}

.main-container {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--neutral-800);
  margin-bottom: 8px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  font-size: 16px;
  color: var(--neutral-600);
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 12px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary-blue);
  color: white;
}

.btn-primary:hover {
  background: var(--secondary-purple);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: white;
  color: var(--neutral-700);
  border: 1px solid var(--neutral-300);
}

.btn-secondary:hover {
  background: var(--neutral-100);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.btn-success {
  background: var(--ai-success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--ai-danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--ai-warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

/* =========================
     CONTROLS & FILTERS
  ========================= */

.controls-bar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid var(--neutral-200);
  border-radius: var(--border-radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.search-filters {
  display: flex;
  gap: 16px;
  align-items: center;
  flex: 1;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  background: white;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--neutral-400);
}

.filter-select {
  padding: 10px 14px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--border-radius-sm);
  background: white;
  font-size: 14px;
  min-width: 120px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* =========================
     EXCEL-STYLE TABLE
  ========================= */

.excel-table-container {
  background: white;
  border: 1px solid var(--neutral-300);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 32px;
}

.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
}

.excel-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: white;
}

.excel-table th {
  background: #f8f9fa;
  border-right: 1px solid #e1e5e9;
  border-bottom: 2px solid #dee2e6;
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--neutral-700);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  user-select: none;
}

.excel-table th:last-child {
  border-right: none;
}

.excel-table td {
  border-right: 1px solid #e1e5e9;
  border-bottom: 1px solid #e1e5e9;
  padding: 8px;
  color: var(--neutral-800);
  vertical-align: top;
  max-width: 300px;
  word-wrap: break-word;
}

.excel-table td:last-child {
  border-right: none;
}

.excel-table tbody tr:hover {
  background: #f8f9fa;
}

.excel-table tbody tr:nth-child(even) {
  background: #fdfdfd;
}

.excel-table tbody tr:nth-child(even):hover {
  background: #f8f9fa;
}

.checkbox-column {
  width: 40px;
  text-align: center;
}

.checkbox-column input[type="checkbox"] {
  transform: scale(1.1);
  cursor: pointer;
}

.sortable {
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.sortable:hover {
  background: #e9ecef !important;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sort-icon {
  opacity: 0.5;
  font-size: 12px;
  transition: opacity var(--transition-fast);
}

.sortable:hover .sort-icon {
  opacity: 1;
}

.sortable.sorted-asc .sort-icon::before {
  content: "\f0de";
  opacity: 1;
  color: var(--primary-blue);
}

.sortable.sorted-desc .sort-icon::before {
  content: "\f0dd";
  opacity: 1;
  color: var(--primary-blue);
}

.actions-column {
  width: 160px;
  text-align: center;
}

/* Status and Priority Badges */
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.in-review {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-badge.approved {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.rejected {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.status-badge.implemented {
  background: rgba(107, 114, 128, 0.1);
  color: var(--neutral-600);
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-badge.urgent {
  background: rgba(220, 38, 38, 0.1);
  color: var(--ai-urgent);
}

.priority-badge.high {
  background: rgba(245, 158, 11, 0.1);
  color: var(--ai-high);
}

.priority-badge.medium {
  background: rgba(16, 185, 129, 0.1);
  color: var(--ai-medium);
}

.priority-badge.low {
  background: rgba(107, 114, 128, 0.1);
  color: var(--ai-low);
}

.type-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.confidence-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.confidence-score.high {
  background: rgba(16, 185, 129, 0.1);
  color: var(--ai-success);
}

.confidence-score.medium {
  background: rgba(245, 158, 11, 0.1);
  color: var(--ai-warning);
}

.confidence-score.low {
  background: rgba(239, 68, 68, 0.1);
  color: var(--ai-danger);
}

.table-cell-title {
  font-weight: 600;
  color: var(--neutral-800);
  margin-bottom: 2px;
}

.table-cell-question {
  font-size: 12px;
  color: var(--neutral-600);
  line-height: 1.3;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.table-action-btn {
  padding: 4px 8px;
  border: 1px solid var(--neutral-300);
  border-radius: 4px;
  background: white;
  color: var(--neutral-600);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.table-action-btn:hover {
  background: var(--neutral-100);
  color: var(--neutral-800);
}

.table-action-btn.primary {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
}

.table-action-btn.primary:hover {
  background: var(--secondary-purple);
  border-color: var(--secondary-purple);
}

.table-action-btn.success {
  background: var(--ai-success);
  color: white;
  border-color: var(--ai-success);
}

.table-action-btn.success:hover {
  background: #059669;
  border-color: #059669;
}

.table-action-btn.danger {
  background: var(--ai-danger);
  color: white;
  border-color: var(--ai-danger);
}

.table-action-btn.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.table-action-btn.warning {
  background: var(--ai-warning);
  color: white;
  border-color: var(--ai-warning);
}

.table-action-btn.warning:hover {
  background: #d97706;
  border-color: #d97706;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-md);
}

.empty-state-icon {
  font-size: 48px;
  color: var(--neutral-400);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 24px;
  font-weight: 700;
  color: var(--neutral-800);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--neutral-600);
  margin-bottom: 24px;
  font-size: 16px;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--neutral-800);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--neutral-500);
  padding: 8px;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--neutral-100);
  color: var(--neutral-800);
}

.modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: 24px;
  border-top: 1px solid var(--neutral-200);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Review Details Modal Specific */
.review-details-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.recommendation-overview {
  background: var(--neutral-50);
  padding: 20px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--neutral-200);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.overview-item {
  text-align: center;
}

.overview-label {
  display: block;
  font-size: 11px;
  color: var(--neutral-500);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.overview-value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-800);
}

.poll-details-section h3,
.response-details-section h3,
.ai-analysis-section h3,
.reviewer-notes-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--neutral-800);
  margin-bottom: 16px;
  border-bottom: 2px solid var(--primary-blue);
  padding-bottom: 8px;
}

.question-display {
  background: var(--neutral-50);
  padding: 20px;
  border-radius: var(--border-radius-md);
  border-left: 4px solid var(--ai-primary);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--neutral-800);
}

.responses-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.response-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--neutral-50);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--neutral-200);
}

.response-number {
  background: var(--ai-primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.response-text {
  flex: 1;
  font-weight: 500;
  color: var(--neutral-800);
}

/* Analysis Tabs */
.analysis-tabs {
  display: flex;
  gap: 2px;
  background: var(--neutral-100);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--neutral-600);
  font-size: 13px;
}

.tab-btn.active {
  background: var(--primary-blue);
  color: white;
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
  background: var(--neutral-200);
  color: var(--neutral-800);
}

.tab-content {
  position: relative;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.analysis-content {
  background: var(--neutral-50);
  padding: 20px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--neutral-200);
  line-height: 1.6;
  color: var(--neutral-700);
}

.form-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: all var(--transition-fast);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--neutral-200);
  border-top: 4px solid var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-overlay p {
  font-size: 16px;
  color: var(--neutral-600);
  font-weight: 500;
}

/* =========================
     RESPONSIVE DESIGN
  ========================= */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .main-container {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
    gap: 16px;
  }

  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-filters {
    flex-direction: column;
  }

  .table-controls {
    justify-content: center;
  }

  .modal-content {
    width: 95%;
    margin: 20px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 16px;
  }

  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .analysis-tabs {
    flex-direction: column;
  }

  .modal-footer {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 24px;
  }

  .modal-content {
    width: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;
  }

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