:root {
  --bg-dark: #f5f7fa;
  --bg-card: #ffffff;
  --bg-input: #f0f2f5;
  --primary: #e42025; /* Vermelho SC */
  --primary-hover: #c51a1e;
  --secondary: #7bbd42; /* Verde SC */
  --accent: #fbc02d;
  --danger: #d32f2f;
  --text-main: #2d3436;
  --text-dim: #636e72;
  --border: #dfe6e9;
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 1000;
  transition: var(--transition);
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-menu {
  list-style: none;
  flex-grow: 1;
}

.nav-item {
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-dim);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.nav-item:hover, .nav-item.active {
  background: var(--bg-input);
  color: var(--text-main);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(228, 32, 37, 0.1);
}

/* Main Content */
.main-content {
  margin-left: 260px;
  flex-grow: 1;
  padding: 40px;
  max-width: calc(100vw - 260px);
  transition: var(--transition);
}

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

h1 { font-size: 2rem; margin-bottom: 8px; }
header p { color: var(--text-dim); }

/* Dashboard Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.875rem;
  margin-bottom: 12px;
  display: block;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

/* Sections */
.section-view {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.section-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Panels */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 28px;
  border-radius: var(--radius);
  height: fit-content;
}

.panel-title {
  font-size: 1.25rem;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 0.875rem;
  color: var(--text-dim);
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

button:hover { background: var(--primary-hover); }
button.secondary { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.danger { background: var(--danger); }
button.danger:hover { opacity: 0.9; }

/* List Items */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  background: var(--bg-input);
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.list-item:hover { transform: translateX(4px); }
.list-item.done { border-left-color: var(--secondary); opacity: 0.7; }

.item-info h4 { margin-bottom: 4px; }
.item-info p { color: var(--text-dim); font-size: 0.875rem; }

/* Progress Bars */
.progress-container {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Edital Grid */
.edital-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.block-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.block-card:hover { border-color: var(--secondary); }

/* Study Material Layout */
.study-layout {
  display: flex;
  gap: 24px;
  min-height: 500px;
}

.study-sidebar {
  width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: fit-content;
  max-height: 80vh;
  position: sticky;
  top: 20px;
  overflow-y: auto;
  padding: 10px;
}

.study-topic-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.study-topic-item:hover {
  background: var(--bg-input);
}

.study-topic-item.active {
  background: rgba(228, 32, 37, 0.1);
  color: var(--primary);
  font-weight: 600;
}

.study-content {
  flex: 1;
  line-height: 1.7;
  font-size: 1.05rem;
  padding: 40px;
}

.study-content h2 { margin: 24px 0 16px; color: var(--primary); }
.study-content h3 { margin: 20px 0 12px; color: var(--secondary); }
.study-content p { margin-bottom: 16px; }
.study-content ul { margin-bottom: 16px; padding-left: 20px; }
.study-content li { margin-bottom: 8px; }

/* Scrollbar Styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Tab Navigation */
.tab-navigation {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  display: flex;
  gap: 10px;
}

.nav-tab {
  background: none;
  border: none;
  padding: 18px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  border-radius: 0;
  height: auto;
  outline: none;
}

.nav-tab:hover {
  color: var(--primary);
  background: rgba(228, 32, 37, 0.04);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Quiz / Stats Panel */
.stats-panel {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stats-counter {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.stats-counter div {
  background: var(--bg-dark);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Question Card & Options */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

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

.question-theme {
  background: rgba(228, 32, 37, 0.08);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-line;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-item {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
}

.option-item:hover {
  background: var(--border);
  border-color: var(--text-dim);
}

.option-item.selected {
  background: rgba(228, 32, 37, 0.05);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.option-badge {
  background: var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 700;
  font-size: 0.8rem;
  min-width: 24px;
  text-align: center;
}

.option-item.selected .option-badge {
  background: var(--primary);
  color: white;
}

/* Response Correction States */
.option-item.correct {
  background: rgba(123, 189, 66, 0.12) !important;
  border-color: var(--secondary) !important;
  color: #274e13 !important;
}

.option-item.correct .option-badge {
  background: var(--secondary) !important;
  color: white !important;
}

.option-item.incorrect {
  background: rgba(211, 47, 47, 0.08) !important;
  border-color: var(--danger) !important;
  color: #7a1c1c !important;
}

.option-item.incorrect .option-badge {
  background: var(--danger) !important;
  color: white !important;
}

/* Explanation / Gabarito Comentado */
.explanation-panel {
  background: #fafbfd;
  border: 1px solid #d0e2ff;
  border-left: 5px solid #0f62fe;
  border-radius: 8px;
  padding: 20px;
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.4s ease-out;
}

.explanation-panel h4 {
  color: #0f62fe;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  margin: 0;
}

/* --- RESPONSIVE DESIGN --- */

@media (max-width: 1024px) {
  .sidebar { width: 80px; padding: 20px 10px; }
  .logo span, .nav-item span { display: none; }
  .main-content { margin-left: 80px; max-width: calc(100vw - 80px); padding: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  
  .sidebar {
    width: 100%;
    height: 70px;
    bottom: 0;
    top: auto;
    left: 0;
    flex-direction: row;
    padding: 0 10px;
    justify-content: space-around;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--border);
    position: fixed;
    background: var(--bg-card);
  }

  .logo { display: none; }
  .nav-menu {
    flex-direction: row;
    width: 100%;
    margin: 0;
    display: flex;
    justify-content: space-around;
  }

  .nav-item {
    margin-bottom: 0;
    padding: 10px;
    flex-direction: column;
    gap: 4px;
    font-size: 0.7rem;
    flex: 1;
    text-align: center;
  }

  .nav-item .icon { font-size: 1.2rem; }
  .nav-item span { display: block; font-size: 0.65rem; }

  #resetBtn { display: none; }

  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 16px;
    padding-bottom: 90px;
  }

  h1 { font-size: 1.5rem; }
  
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 1.25rem; }

  .study-layout { flex-direction: column; height: auto; }
  .study-sidebar { 
    width: 100%; 
    height: auto; 
    max-height: 150px; 
    display: flex; 
    overflow-x: auto; 
    overflow-y: hidden;
    white-space: nowrap;
    gap: 8px;
    padding: 12px;
    background: var(--bg-input);
    margin-bottom: 16px;
  }
  
  .study-topic-item { 
    display: inline-block; 
    flex-shrink: 0;
    padding: 8px 16px;
    border: 1px solid var(--border);
    margin-bottom: 0;
  }

  .study-content { padding: 20px; font-size: 1rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .nav-item span { display: none; }
  header { flex-direction: column; gap: 12px; }
}