/* ----------------------------------------------
   DESIGN TOKENS
   ---------------------------------------------- */
:root {
  --brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --brand-primary: #667eea;
  --brand-secondary: #764ba2;
  --danger: #dc3545;
  --warning: #ffc107;
  --success: #28a745;
  --text: #333;
  --text-muted: #666;
  --bg: #f4f4f4;
  --card-bg: #fff;
  --border: #e2e8f0;
}

*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------
   BASE & RESET
   ---------------------------------------------- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

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

/* ----------------------------------------------
   HEADER
   ---------------------------------------------- */
header {
  background: var(--brand-gradient);
  color: #fff;
  width: 100%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
}

.site-title {
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 2rem;
  font-size: 1.1rem;
  position: relative;
  transition: color 0.3s ease;
}

nav a:first-child {
  margin-left: 0;
}

nav a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 0;
  background-color: #fff;
  transition: width 0.3s ease;
}

nav a:hover {
  color: #f0f0f0;
}

nav a:hover::after {
  width: 100%;
}

/* ----------------------------------------------
   FOOTER
   ---------------------------------------------- */
footer {
  background: var(--brand-gradient);
  color: #fff;
  width: 100%;
  margin-top: auto;
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-copyright {
  font-size: 0.95rem;
  opacity: 0.9;
}

.footer-links a {
  color: #fff;
  text-decoration: none;
  margin-left: 2rem;
  font-size: 0.95rem;
  position: relative;
  transition: color 0.3s ease;
  opacity: 0.9;
}

.footer-links a:first-child {
  margin-left: 0;
}

.footer-links a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 0;
  background-color: #fff;
  transition: width 0.3s ease;
}

.footer-links a:hover {
  opacity: 1;
}

.footer-links a:hover::after {
  width: 100%;
}

/* ----------------------------------------------
   MAIN CONTENT
   ---------------------------------------------- */
main {
  flex: 1;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
  width: 100%;
}

h1 {
  margin-bottom: 1rem;
  color: #444;
}

/* ----------------------------------------------
   COURSE GRID & CARDS (Dashboard)
   ---------------------------------------------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.course-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.course-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.card-content {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-content h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  color: #333;
}

.card-content p {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.image-placeholder {
  background-color: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #999;
  height: 150px;
}

.btn {
  display: inline-block;
  background: var(--brand-gradient);
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  text-align: center;
  transition: opacity 0.2s;
  border: none;
  cursor: pointer;
  align-self: flex-start;
}

.btn:hover {
  opacity: 0.9;
}

/* ----------------------------------------------
   FORM STYLES
   ---------------------------------------------- */
form div {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

input, textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
}

button {
  background: #333;
  color: #fff;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #555;
}

/* Submit buttons match the .btn brand styling */
button[type="submit"] {
  background: var(--brand-gradient);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  border: none;
  font-weight: 500;
  cursor: pointer;
}

button[type="submit"]:hover {
  opacity: 0.9;
  background: var(--brand-gradient);
}

/* ----------------------------------------------
   FOCUS STATES (WCAG 2.1)
   ---------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

input:focus, textarea:focus {
  border-color: var(--brand-primary);
  outline: none;
}

/* ----------------------------------------------
   PROGRESS BAR
   ---------------------------------------------- */
.progress-bar {
  background-color: #eee;
  height: 10px;
  border-radius: 5px;
  margin: 10px 0;
}

.progress {
  background-color: var(--success);
  height: 10px;
  border-radius: 5px;
}

/* ----------------------------------------------
   IN-PROGRESS CARD (Dashboard "Continue Learning")
   ---------------------------------------------- */
.in-progress-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin: 1.5rem 0 2.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-left: 4px solid var(--brand-primary);
}
.in-progress-card h2 { margin-top: 0; color: var(--text); }
.in-progress-card h3 { margin: 0.25rem 0; }

/* ----------------------------------------------
   ERROR MESSAGES
   ---------------------------------------------- */
.error-message {
  background: #fee;
  border: 1px solid var(--danger);
  color: #a00;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* ----------------------------------------------
   LOGOUT FORM (inline in nav)
   ---------------------------------------------- */
.logout-form {
  display: inline;
  margin-left: 2rem;
}
.logout-btn {
  background: transparent;
  color: #fff;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 1.1rem;
}
.logout-btn:hover {
  text-decoration: underline;
  background: transparent;
}

/* ----------------------------------------------
   LESSON PAGE STYLES
   ---------------------------------------------- */
.breadcrumb {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a {
  color: var(--brand-primary);
  text-decoration: none;
}
.breadcrumb a:hover {
  text-decoration: underline;
}
.breadcrumb span {
  color: #999;
}

main h1 {
  font-size: 2rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 1rem;
  border-left: 4px solid var(--brand-primary);
  padding-left: 1rem;
}

.lesson-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  overflow: hidden;
  margin-top: 1rem;
}

.lesson-header {
  background: var(--brand-gradient);
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.lesson-header h2 {
  margin: 0;
  font-size: 1.8rem;
}
.lesson-meta {
  font-size: 0.9rem;
  background: rgba(255,255,255,0.2);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
}

.lesson-content {
  padding: 2rem;
  line-height: 1.7;
  color: #333;
}
.lesson-content h2,
.lesson-content h3 {
  margin-top: 1.5rem;
  color: #444;
}
.lesson-content ul,
.lesson-content ol {
  margin: 1rem 0 1rem 1.5rem;
}
.lesson-content code {
  background: #f4f4f4;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
}

.lesson-nav {
  border-top: 1px solid #eee;
  padding: 1.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: #fafafa;
}
.page-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.page-nav .btn,
.page-nav .btn-disabled {
  min-width: 120px;
  text-align: center;
}
.btn-disabled {
  background: #ccc;
  color: #666;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: not-allowed;
  display: inline-block;
}
.next-lesson {
  flex: 1;
  text-align: right;
}
.next-lesson .btn-primary {
  background: linear-gradient(135deg, #28a745 0%, #218838 100%);
}
.next-lesson .btn-primary:hover {
  opacity: 0.9;
}

.back-link {
  padding: 1rem 2rem 2rem;
  text-align: center;
}
.back-link-top {
  margin-bottom: 1rem;
}
.btn-secondary {
  background: #6c757d;
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.btn-secondary:hover {
  background: #5a6268;
}

.page-step-bar {
  margin-top: 1rem;
  background: #e2e8f0;
  border-radius: 12px;
  height: 6px;
  width: 100%;
  overflow: hidden;
}
.page-step-progress {
  background: var(--brand-gradient);
  height: 100%;
  width: 0%;
  border-radius: 12px;
  transition: width 0.3s ease;
}

/* ----------------------------------------------
   PASSWORD CHECKER WIDGET
   ---------------------------------------------- */
.password-checker {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 2rem;
  border: 1px solid var(--border);
}
.password-input {
  width: 100%;
  padding: 0.75rem;
  margin: 0.5rem 0;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  font-size: 1rem;
}
.strength-meter {
  height: 8px;
  background-color: var(--border);
  border-radius: 4px;
  margin: 0.5rem 0;
  overflow: hidden;
}
.strength-meter-fill {
  height: 100%;
  width: 0%;
  background-color: var(--danger);
  transition: width 0.2s, background-color 0.2s;
}
.strength-text {
  font-weight: bold;
  margin: 0.5rem 0;
}
.crack-time {
  font-size: 0.9rem;
  color: #4a5568;
  margin: 0.25rem 0;
}
.crack-time-note {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}
.feedback {
  font-size: 0.9rem;
  color: #e53e3e;
  margin-top: 0.25rem;
}

/* ----------------------------------------------
   FORUM
   ---------------------------------------------- */
.forum-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.forum-list {
  margin-top: 2rem;
}
.forum-topic-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.forum-topic-card a {
  text-decoration: none;
  color: var(--brand-primary);
}
.forum-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.forum-post {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.forum-post-meta {
  font-weight: bold;
  margin-bottom: 0.5rem;
}
.forum-post-body {
  white-space: pre-wrap;   /* preserves line breaks safely */
}
.reply-section {
  margin-top: 2rem;
}
.reply-section textarea {
  width: 100%;
  padding: 0.5rem;
}

/* ----------------------------------------------
   TEACHER RESOURCES GRID
   ---------------------------------------------- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}
.resource-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ----------------------------------------------
   RESPONSIVE ADJUSTMENTS
   ---------------------------------------------- */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }

  .site-title {
    margin-bottom: 0.5rem;
    font-size: 1.6rem;
  }

  nav a {
    margin-left: 0;
    margin-right: 2rem;
    display: inline-block;
  }

  nav a:first-child {
    margin-left: 0;
  }

  .logout-form {
    margin-left: 0;
    margin-right: 2rem;
  }

  .footer-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1rem;
  }

  .footer-links a {
    margin: 0 1rem 0.5rem;
    display: inline-block;
  }

  .footer-links a:first-child {
    margin-left: 1rem;
  }

  main {
    padding: 1rem;
    margin: 1rem auto;
  }

  h1 {
    font-size: 1.8rem;
  }

  input, textarea, button {
    font-size: 16px; /* prevents zoom on iOS */
  }

  .course-card img {
    height: 160px;
  }

  .lesson-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .lesson-nav {
    flex-direction: column;
    align-items: stretch;
  }
  .page-nav {
    justify-content: center;
  }
  .next-lesson {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0.75rem;
  }

  nav a {
    margin-right: 1rem;
    font-size: 1rem;
  }

  .footer-container {
    padding: 1rem;
  }

  .footer-links a {
    margin: 0 0.75rem;
    font-size: 0.9rem;
  }

  .course-card img {
    height: 140px;
  }

  .card-content {
    padding: 1rem;
  }

  .lesson-content {
    padding: 1.5rem;
  }
}
