/* ==============================================
   DASHBOARD STYLES
   Sidebar, filters, KPIs, charts, tables
   ============================================== */

/* ==============================================
   DASHBOARD LAYOUT
   ============================================== */

.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 200px);
}

.dashboard-layout > .sidebar-overlay {
  display: none;
}

.dashboard-sidebar {
  background: var(--bg-light);
  border-right: 1px solid #e2e8f0;
  padding: var(--spacing-md) 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

.dashboard-main {
  padding: var(--spacing-lg);
  background: var(--bg-grey);
  min-width: 0;
}

/* Full-width layout (no sidebar) */
.dashboard-full {
  padding: var(--spacing-lg);
  background: var(--bg-grey);
}

/* ==============================================
   SIDEBAR
   ============================================== */

.sidebar-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-medium);
  padding: var(--spacing) var(--spacing-md);
  margin: 0;
  font-weight: 600;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  margin: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-dark);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(46, 125, 110, 0.06);
  color: var(--primary-color);
}

.sidebar-nav a.active {
  background: rgba(46, 125, 110, 0.08);
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  font-weight: 600;
}

.sidebar-nav a i {
  width: 20px;
  text-align: center;
  font-size: 0.85rem;
}

/* Sidebar collapsible groups */
.sidebar-group {
  border-bottom: 1px solid #f1f5f9;
}

.sidebar-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px var(--spacing-md);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
  transition: all var(--transition-fast);
}

.sidebar-group-toggle:hover {
  background: rgba(46, 125, 110, 0.04);
  color: var(--primary-color);
}

.sidebar-group-arrow {
  font-size: 0.6rem;
  color: var(--text-medium);
  transition: transform var(--transition-fast);
}

.sidebar-group.open .sidebar-group-arrow {
  transform: rotate(180deg);
}

.sidebar-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sidebar-group.open .sidebar-group-items {
  max-height: 120px;
}

.sidebar-group-items a {
  padding-left: calc(var(--spacing-md) + 12px);
  font-size: 0.84rem;
}

/* Plano de Ação link in sidebar */
.sidebar-plano-link {
  background: rgba(253, 184, 19, 0.08);
  border-left: 3px solid var(--accent-color) !important;
  font-weight: 600 !important;
  color: var(--primary-dark) !important;
}

.sidebar-plano-link:hover {
  background: rgba(253, 184, 19, 0.15) !important;
}

.sidebar-divider {
  height: 1px;
  background: #e2e8f0;
  margin: var(--spacing-sm) var(--spacing-md);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  z-index: var(--z-fixed);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

/* ==============================================
   TITLE BAR (Dashboard header)
   ============================================== */

.dash-title-bar {
  background: var(--bg-light);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing);
}

.dash-title-bar h2 {
  font-size: 1.4rem;
  color: var(--primary-dark);
  margin: 0;
}

.dash-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.dash-badge i {
  font-size: 0.7rem;
}

/* ==============================================
   FILTER BAR
   ============================================== */

.filter-bar {
  display: flex;
  gap: var(--spacing);
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-medium);
  font-weight: 600;
}

.filter-group select {
  padding: 8px 32px 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-dark);
  background: white;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23666' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 180px;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 125, 110, 0.1);
}

/* ==============================================
   KPI SCORECARDS
   ============================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing);
  margin-bottom: var(--spacing-lg);
}

.kpi-card {
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  text-align: center;
  transition: all var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-value {
  font-family: 'Poppins', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 500;
}

.kpi-card.accent .kpi-value {
  color: var(--accent-dark);
}

/* ==============================================
   CHART CONTAINERS
   ============================================== */

.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.chart-card {
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
}

.chart-card h3 {
  font-size: 1rem;
  color: var(--text-dark);
  margin-bottom: var(--spacing);
  padding-bottom: var(--spacing-xs);
  border-bottom: 2px solid var(--bg-grey);
  font-weight: 600;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  max-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-wrapper canvas {
  max-height: 300px;
}

/* Full-width chart */
.chart-card.full {
  grid-column: 1 / -1;
}

.chart-card.full .chart-wrapper {
  max-height: 450px;
}

.chart-card.full .chart-wrapper canvas {
  max-height: 420px;
}

/* ==============================================
   SCORE LEGEND
   ============================================== */

.score-legend {
  display: flex;
  gap: var(--spacing);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing);
  background: var(--bg-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
}

.score-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dark);
}

.score-legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.score-legend-item span:last-child {
  color: var(--text-medium);
  font-size: 0.8rem;
}

/* ==============================================
   QUESTION BREAKDOWN
   ============================================== */

.questions-section h3 {
  font-size: 1.1rem;
  color: var(--text-dark);
  margin-bottom: var(--spacing);
  font-weight: 600;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing);
}

.question-card {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: var(--spacing);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  transition: all var(--transition-fast);
}

.question-card:hover {
  box-shadow: var(--shadow);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.question-number {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-color);
}

.question-correct {
  font-size: 0.8rem;
  color: var(--text-medium);
}

.question-correct strong {
  color: var(--primary-color);
}

.question-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.question-bar-label {
  width: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-medium);
  text-align: center;
}

.question-bar-label.correct {
  color: var(--primary-color);
}

.question-bar-track {
  flex: 1;
  height: 18px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.question-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  min-width: 0;
}

.question-bar-fill.correct {
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.question-bar-fill.wrong {
  background: #e2e8f0;
}

.question-bar-count {
  font-size: 0.7rem;
  color: var(--text-medium);
  width: 28px;
  text-align: right;
}

/* Habilidade toggle button */
.habilidade-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--spacing-sm);
  padding: 6px 10px;
  background: rgba(46, 125, 110, 0.08);
  border: 1px solid rgba(46, 125, 110, 0.2);
  border-radius: var(--radius-sm);
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  justify-content: center;
}

.habilidade-toggle:hover {
  background: rgba(46, 125, 110, 0.14);
  border-color: var(--primary-color);
}

.habilidade-toggle .fa-lightbulb {
  color: var(--accent-color);
}

.habilidade-arrow {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}

.habilidade-content.open + .habilidade-toggle .habilidade-arrow,
.habilidade-content.open ~ .habilidade-toggle .habilidade-arrow {
  transform: rotate(180deg);
}

/* Habilidade expandable content */
.habilidade-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 var(--spacing-sm);
}

.habilidade-content.open {
  max-height: 200px;
  padding: var(--spacing-sm);
  margin-top: 6px;
  background: rgba(253, 184, 19, 0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-color);
}

.habilidade-content p {
  font-size: 0.82rem;
  color: var(--text-dark);
  line-height: 1.5;
  margin: 0;
}

/* ==============================================
   DATA TABLE
   ============================================== */

.data-table-wrapper {
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  overflow-x: auto;
}

.data-table-wrapper h3 {
  font-size: 1rem;
  color: var(--text-dark);
  margin-bottom: var(--spacing);
  padding-bottom: var(--spacing-xs);
  border-bottom: 2px solid var(--bg-grey);
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.data-table th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-dark);
}

.data-table tbody tr:hover {
  background: rgba(46, 125, 110, 0.03);
}

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

.data-table .number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ==============================================
   LOADING STATE
   ============================================== */

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  gap: var(--spacing);
  color: var(--text-medium);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.9rem;
}

/* No data state */
.no-data-message {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-lg);
  color: var(--text-medium);
}

.no-data-message i {
  font-size: 2.5rem;
  color: var(--primary-light);
  margin-bottom: var(--spacing);
  display: block;
  opacity: 0.6;
}

.no-data-message p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: var(--spacing-xs);
}

.no-data-message span {
  font-size: 0.9rem;
}

/* Error state */
.error-message {
  text-align: center;
  padding: var(--spacing-xl);
  color: #dc3545;
}

.error-message i {
  font-size: 2rem;
  margin-bottom: var(--spacing);
  display: block;
}

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

@media (max-width: 1023px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    z-index: var(--z-modal);
    overflow-y: auto;
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .dashboard-sidebar.open {
    display: block;
  }

  .dashboard-layout > .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-modal) - 1);
  }

  .dashboard-layout > .sidebar-overlay.open {
    display: block;
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: var(--spacing) var(--spacing-md);
  }

  .sidebar-close button {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-medium);
    cursor: pointer;
    padding: 4px 8px;
  }
}

@media (max-width: 767px) {
  .dashboard-main,
  .dashboard-full {
    padding: var(--spacing);
  }

  .dash-title-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--spacing);
  }

  .dash-title-bar h2 {
    font-size: 1.1rem;
  }

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

  .filter-group select {
    min-width: unset;
    width: 100%;
  }

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

  .charts-row {
    grid-template-columns: 1fr;
  }

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

  .score-legend {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 1.6rem;
  }
}
