:root {
  --aws-orange: #ff9900;
  --aws-blue: #232f3e;
  --aws-light-blue: #3e5164;
  --bg-color: #f2f3f3;
  --card-bg: #ffffff;
  --text-primary: #16191f;
  --text-secondary: #545b64;
  --success: #1d8102;
  --error: #d13212;
  --border-radius: 12px;
  --shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header & Nav */
header {
  background-color: var(--aws-blue);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.logo {
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
  font-size: 0.9rem;
}

.nav-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
  background: var(--aws-orange);
  color: var(--aws-blue);
}

/* Main Content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

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

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 153, 0, 0.3);
  border-radius: 50%;
  border-top-color: var(--aws-orange);
  animation: spin 1s ease-in-out infinite;
}

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

/* Quiz Section */
.quiz-header {
  margin-bottom: 2rem;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--aws-orange);
  width: 0%;
  transition: width 0.5s ease-out;
}

.stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.quiz-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--aws-blue);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  text-align: left;
  background: #f8f9fa;
  border: 2px solid transparent;
  padding: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
  color: var(--text-primary);
}

.option-btn:hover:not(:disabled) {
  background: #e9ecef;
  transform: translateX(4px);
}

.option-btn.selected {
  border-color: var(--aws-orange);
  background: rgba(255, 153, 0, 0.1);
}

.option-btn.correct {
  background: rgba(29, 129, 2, 0.1);
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}

.option-btn.incorrect {
  background: rgba(209, 50, 18, 0.1);
  border-color: var(--error);
  opacity: 0.7;
}

.quiz-controls {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

button {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  font-weight: 600;
  transition: var(--transition);
}

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

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 153, 0, 0.3);
}

.secondary-btn {
  background: #e0e0e0;
  color: var(--text-secondary);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.danger-btn {
  background: #ffebe9;
  color: var(--error);
}

/* Study Section */
.filters {
  margin-bottom: 1.5rem;
}

#study-search {
  width: 100%;
  padding: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--border-radius);
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}

#study-search:focus {
  border-color: var(--aws-orange);
}

.study-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--aws-blue);
}

.study-question {
  font-weight: 600;
  margin-bottom: 1rem;
}

.study-options {
  list-style: none;
  margin-bottom: 1rem;
}

.study-options li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.study-options li:last-child {
  border-bottom: none;
}

.reveal-btn {
  background: var(--aws-light-blue);
  color: white;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  width: 100%;
}

.answer-reveal {
  margin-top: 1rem;
  padding: 1rem;
  background: #f0fdf4;
  border-radius: 8px;
  color: var(--success);
  font-weight: 600;
  display: none;
}

.answer-reveal.visible {
  display: block;
  animation: slideDown 0.3s ease-out;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
  padding: 1rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

#study-page-info {
  font-weight: 600;
  color: var(--aws-blue);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cheat Sheet Section */
.cs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.cs-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

#cs-search {
  padding: 0.5rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 20px;
  outline: none;
  min-width: 200px;
}

#cs-search:focus {
  border-color: var(--aws-orange);
}

.table-container {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

th {
  background: var(--aws-light-blue);
  color: white;
  font-weight: 600;
  position: sticky;
  top: 0;
}

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

tr:hover td {
  background: #f8f9fa;
}

.cs-key {
  font-weight: 600;
  color: var(--aws-blue);
  font-size: 0.95rem;
}

.cs-val {
  color: var(--success);
  font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-btn {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
  }

  .quiz-controls {
    flex-direction: column-reverse;
  }

  .quiz-controls button {
    width: 100%;
  }

  .cs-header {
    flex-direction: column;
    align-items: stretch;
  }

  .cs-controls {
    flex-direction: column;
  }

  #cs-search {
    width: 100%;
  }

  .pagination-controls {
    flex-direction: column;
    gap: 1rem;
  }

  .pagination-controls button {
    width: 100%;
  }
}

/* Topic Badges */
.topic-badge,
.table-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
}

/* Base default color */
.topic-badge,
.table-badge {
  background-color: #6c757d;
}

/* Dynamic topic colors */
[data-topic='Compute'] {
  background-color: #e67e22;
}

[data-topic='Storage'] {
  background-color: #27ae60;
}

[data-topic='Database'] {
  background-color: #3498db;
}

[data-topic='Networking'] {
  background-color: #9b59b6;
}

[data-topic='Security'] {
  background-color: #e74c3c;
}

[data-topic='Management'] {
  background-color: #34495e;
}

[data-topic='Billing & Pricing'] {
  background-color: #1abc9c;
}

[data-topic='Global Infrastructure'] {
  background-color: #d35400;
}

[data-topic='Support Services'] {
  background-color: #7f8c8d;
}

[data-topic='Migration & Transfer'] {
  background-color: #f39c12;
}

[data-topic='Machine Learning'] {
  background-color: #2c3e50;
}

[data-topic='Analytics'] {
  background-color: #8e44ad;
}

[data-topic='Developer Tools'] {
  background-color: #2980b9;
}

[data-topic='App Integration'] {
  background-color: #16a085;
}

[data-topic='Cloud Concepts'] {
  background-color: #95a5a6;
}

.study-card-header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f0f0f0;
}

.table-badge {
  font-size: 0.75rem;
  white-space: nowrap;
}

.topic-header-row {
  background-color: #e8ecef !important;
}

.topic-header-cell {
  padding: 0.8rem 1.5rem !important;
}

.topic-header-content {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--aws-blue);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cs-topic-badge {
  width: 1%;
  /* Collapse width */
  vertical-align: middle;
}

/* Mock Exam Setup & Results Styles */
.quiz-view {
  display: none;
}

.quiz-view.active-view {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

.setup-form {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
  margin-top: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--aws-blue);
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.radio-group label {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.topics-grid label {
  font-weight: normal;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.text-btn {
  background: none;
  border: none;
  color: var(--aws-orange);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  text-decoration: underline;
}

.large-btn {
  width: 100%;
  font-size: 1.1rem;
  padding: 1rem;
}

.timer-badge {
  background: var(--aws-blue);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-family: monospace;
  font-size: 1rem;
}

.results-header {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.score-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--bg-color);
  border: 8px solid var(--aws-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2rem auto;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--aws-blue);
}

.result-badge {
  display: inline-block;
  padding: 0.5rem 2rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1.2rem;
  margin-top: 1.5rem;
  color: white;
}

.result-badge.pass {
  background: var(--success);
}

.result-badge.fail {
  background: var(--error);
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.weak-topics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

/* Flashcards Section */
.flashcards-header {
  text-align: center;
  margin-bottom: 2rem;
}

.flashcards-header p {
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

#flashcards-unit-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.flashcard-container {
  perspective: 1000px;
  margin-bottom: 2rem;
}

#flashcard {
  width: 100%;
  height: 400px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
  cursor: pointer;
}

#flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.flashcard-front {
  background: white;
  border: 3px solid var(--aws-orange);
}

.flashcard-back {
  background: var(--aws-blue);
  color: white;
  transform: rotateY(180deg);
}

#flashcard-keyword {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  color: var(--aws-orange);
  margin-bottom: 20px;
}

#flashcard-hint {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
}

.flashcard-front .click-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 15px;
}

#flashcard-service {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
}

#flashcard-description {
  font-size: 1.15rem;
  text-align: center;
  line-height: 1.6;
}

.flashcard-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 2rem;
}

#flashcard-know {
  background: #1d8102;
}

#flashcard-learning {
  background: var(--aws-orange);
}

.flashcard-stats {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.flashcard-stats-header {
  text-align: center;
  font-weight: 600;
  margin-bottom: 12px;
}

.flashcard-progress-bar {
  background: #e5e7eb;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 15px;
}

#flashcard-progress {
  background: var(--aws-orange);
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}

.flashcard-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  text-align: center;
}

.flashcard-stat-box {
  padding: 12px;
  background: var(--bg-color);
  border-radius: 8px;
}

.flashcard-stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--aws-blue);
}

.flashcard-stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Study Table Section */
.study-table-header {
  text-align: center;
  margin-bottom: 2rem;
}

.study-table-header p {
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.study-table-controls {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#table-search {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 15px;
}

#table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
}

.study-table-container {
  overflow-x: auto;
}

.study-table-container table {
  width: 100%;
  border-collapse: collapse;
}

.study-table-container thead {
  background: var(--aws-blue);
  color: white;
}

.study-table-container th {
  padding: 12px;
  text-align: left;
}

/* Game Section */
.game-header {
  text-align: center;
}

.game-header p {
  color: var(--text-secondary);
  margin: 1rem 0 2rem;
}

.game-header h3 {
  margin-bottom: 1.5rem;
}

#game-unit-selection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 2rem;
}

.game-stats {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.game-stats-inner {
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.game-stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--aws-blue);
}

.game-stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.game-question-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#game-scenario {
  font-size: 1.3rem;
  margin-bottom: 30px;
  text-align: center;
  line-height: 1.6;
}

#game-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.game-option {
  padding: 20px;
  border: 3px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  background: white;
}

.game-option-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--aws-blue);
  margin-bottom: 5px;
}

.game-option-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

#game-feedback {
  display: none;
  margin-top: 20px;
  padding: 20px;
  border-radius: 10px;
}

#game-next {
  width: 100%;
  margin-top: 20px;
  display: none;
}

.game-results {
  text-align: center;
}

.game-score-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--aws-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 30px auto;
  box-shadow: 0 10px 30px rgba(255, 153, 0, 0.3);
}

#game-final-score {
  color: white;
  font-size: 3rem;
  font-weight: 700;
}

.game-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 30px 0;
}

.game-result-box {
  padding: 20px;
  border-radius: 10px;
}

.game-result-correct {
  background: #d1fae5;
  color: #065f46;
}

.game-result-incorrect {
  background: #fee2e2;
  color: #991b1b;
}

.game-result-accuracy {
  background: #dbeafe;
  color: #1e40af;
}

.game-result-number {
  font-size: 2.5rem;
  font-weight: 700;
}

.game-results-buttons {
  display: flex;
  gap: 15px;
  margin-top: 30px;
}

.game-results-buttons button {
  flex: 1;
}

/* Mobile responsiveness for new sections */
@media (max-width: 600px) {
  #flashcard {
    height: 350px;
  }

  .flashcard-controls {
    grid-template-columns: 1fr;
  }

  #game-options {
    grid-template-columns: 1fr;
  }

  .game-results-grid {
    grid-template-columns: 1fr;
  }

  .game-results-buttons {
    flex-direction: column;
  }
}
