/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  padding: 0;
  margin: 0;
}

.page-wrapper {
  padding: 20px;
  /* push content below the iOS nav bar + safe area */
  padding-top: calc(20px + env(safe-area-inset-top) + 44px); /* 44px ≈ standard nav bar height */
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* Add extra padding on iOS devices to account for navigation bar */
@supports (-webkit-touch-callout: none) {
  .page-wrapper {
    padding-top: 20px;
  }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Flash Messages */
.notice, .alert {
  padding: 15px 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-weight: 500;
}

.notice {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-small, .btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background-color: #545b62;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  margin-right: 0;
  white-space: nowrap;
}

.btn-tiny {
  padding: 4px 8px;
  font-size: 11px;
  margin-right: 0;
  white-space: nowrap;
}

.btn-danger {
  background-color: #dc3545;
  color: white;
}

.btn-danger:hover {
  background-color: #c82333;
}

/* Make small danger buttons less prominent */
.btn-small.btn-danger {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #dc3545;
  font-size: 12px;
  padding: 5px 10px;
}

.btn-small.btn-danger:hover {
  background-color: #dc3545;
  color: white;
}

/* Make tiny danger buttons even less prominent */
.btn-tiny.btn-danger {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  font-size: 10px;
  padding: 3px 8px;
}

.btn-tiny.btn-danger:hover {
  background-color: #dc3545;
  color: white;
}

/* Dashboard */
.dashboard {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dashboard .header {
  position: static; /* ensure normal flow */
  top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 20px;
}

.dashboard h1 {
  font-size: 32px;
  color: #2c3e50;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 24px;
  color: #495057;
}

.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.child-card {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 20px;
  border: 2px solid #dee2e6;
}

.child-card h3 {
  font-size: 20px;
  color: #2c3e50;
  margin-bottom: 10px;
}

.child-info {
  color: #6c757d;
  margin-bottom: 15px;
  font-size: 14px;
}

.status {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 15px;
  text-align: center;
}

.status.completed {
  background-color: #d4edda;
  color: #155724;
}

.status.pending {
  background-color: #fff3cd;
  color: #856404;
}

.feedback-section {
  background: #e8f4f8;
  border-left: 4px solid #17a2b8;
  padding: 15px;
  margin: 15px 0;
  border-radius: 6px;
}

.feedback-section h4 {
  color: #0c5460;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feedback-text {
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.child-actions {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.empty-state {
  text-align: center;
  color: #6c757d;
  padding: 40px;
  font-size: 18px;
}

/* Forms */
.form-container {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.form-container h1 {
  margin-bottom: 25px;
  color: #2c3e50;
}

.form-field {
  margin-bottom: 20px;
}

.form-field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #495057;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 16px;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: #007bff;
}

.form-actions {
  margin-top: 25px;
  display: flex;
  gap: 10px;
}

.error-messages {
  background-color: #f8d7da;
  color: #721c24;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 20px;
}

.error-messages h3 {
  margin-bottom: 10px;
}

.error-messages ul {
  margin-left: 20px;
}

/* Reading Session */
.reading-session {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 900px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.reading-header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
}

.reading-header h1 {
  color: #2c3e50;
  margin-bottom: 10px;
}

.child-name {
  font-size: 18px;
  color: #6c757d;
}

.passage-section {
  margin-bottom: 40px;
}

.passage-title {
  text-align: center;
  color: #495057;
  margin-bottom: 20px;
}

.passage-content {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 8px;
  line-height: 2.2;
  font-size: 20px;
  margin-bottom: 15px;
  text-align: justify;
}

.word {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
  user-select: none;
  display: inline-block;
}

.word:hover {
  background-color: #e9ecef;
}

.word.tapped {
  background-color: #ffc107;
  font-weight: bold;
}

.instruction {
  text-align: center;
  color: #6c757d;
  font-style: italic;
  font-size: 14px;
}

.teaching-notes-panel {
  background: #fff9e6;
  border: 3px solid #ffc107;
  border-radius: 10px;
  padding: 20px;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.teaching-notes-panel h3 {
  color: #856404;
  margin-bottom: 15px;
  font-size: 20px;
  border-bottom: 2px solid #ffc107;
  padding-bottom: 10px;
}

.teaching-notes-word {
  font-size: 18px;
  color: #2c3e50;
  margin-bottom: 15px;
  padding: 10px;
  background: white;
  border-radius: 6px;
  border-left: 4px solid #ffc107;
}

.teaching-note {
  background: white;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border-left: 4px solid #17a2b8;
}

.teaching-note:last-child {
  margin-bottom: 15px;
}

.teaching-note h4 {
  color: #17a2b8;
  font-size: 16px;
  margin-bottom: 8px;
  font-weight: 600;
}

.teaching-note p {
  color: #495057;
  line-height: 1.6;
  margin: 0;
  font-size: 15px;
}

.comprehension-section {
  margin-bottom: 40px;
}

.comprehension-section h2 {
  color: #2c3e50;
  margin-bottom: 15px;
}

.questions {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  border: 2px solid #dee2e6;
}

.question-text {
  font-size: 18px;
  color: #2c3e50;
  margin-bottom: 10px;
  font-weight: 500;
}

.question-type {
  font-size: 14px;
  color: #6c757d;
  margin-bottom: 15px;
  font-style: italic;
}

.star-rating {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.star {
  font-size: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: #dee2e6;
  transition: color 0.2s;
}

.star:hover {
  color: #ffd700;
}

.star.selected {
  color: #ffd700;
}

.question-card textarea.notes {
  width: 100%;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

.session-notes {
  margin-bottom: 30px;
}

.session-notes h3 {
  color: #495057;
  margin-bottom: 15px;
}

.session-notes textarea {
  width: 100%;
  padding: 15px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}

.session-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

/* Skills Dashboard */
.skills-dashboard {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 1400px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.skills-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
}

.skills-header h1 {
  color: #2c3e50;
}

.skills-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 10px;
  text-align: center;
  border: 2px solid #dee2e6;
}

.stat-card h3 {
  font-size: 36px;
  color: #2c3e50;
  margin-bottom: 5px;
}

.stat-card p {
  color: #6c757d;
  font-size: 14px;
  margin: 0;
}

.stat-card.success {
  background: #d4edda;
  border-color: #c3e6cb;
}

.stat-card.success h3 {
  color: #155724;
}

.stat-card.warning {
  background: #fff3cd;
  border-color: #ffeaa7;
}

.stat-card.warning h3 {
  color: #856404;
}

.skills-by-type {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.skill-type-section h2 {
  color: #495057;
  margin-bottom: 20px;
  font-size: 22px;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

.skill-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #dee2e6;
}

.skill-card.mastered {
  background: #d4edda;
  border-left-color: #28a745;
}

.skill-card.needs-review {
  background: #fff3cd;
  border-left-color: #ffc107;
}

.skill-card.in-progress {
  background: #d1ecf1;
  border-left-color: #17a2b8;
}

.skill-name {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.skill-description {
  font-size: 13px;
  color: #6c757d;
  margin-bottom: 15px;
}

.skill-stats {
  margin-top: 15px;
}

.mastery-bar {
  background: #e9ecef;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.mastery-fill {
  background: linear-gradient(90deg, #ffc107 0%, #28a745 100%);
  height: 100%;
  transition: width 0.3s ease;
}

.mastery-details {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #6c757d;
}

.mastery-percent {
  font-weight: 600;
  color: #2c3e50;
}

.exposure-count {
  font-style: italic;
}

.last-practiced {
  font-size: 11px;
}

/* Grade Level Section */
.grade-level-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 40px;
  color: white;
}

.grade-level-section h2 {
  color: white;
  font-size: 26px;
  margin-bottom: 10px;
}

.grade-level-intro {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  margin-bottom: 25px;
}

.current-grade-banner {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 15px 20px;
  margin-bottom: 25px;
  display: inline-flex;
  align-items: center;
  gap: 15px;
}

.current-grade-banner .label {
  font-size: 16px;
  font-weight: 500;
}

.grade-badge {
  background: white;
  color: #667eea;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 18px;
}

.grade-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.grade-level-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  color: #2c3e50;
  transition: transform 0.2s, box-shadow 0.2s;
}

.grade-level-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.grade-level-card.current {
  border: 3px solid #ffd700;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.grade-level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.grade-level-header h3 {
  font-size: 20px;
  color: #2c3e50;
  margin: 0;
}

.confidence-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 16px;
}

.confidence-badge.high {
  background: #28a745;
  color: white;
}

.confidence-badge.medium {
  background: #ffc107;
  color: #333;
}

.confidence-badge.low {
  background: #e9ecef;
  color: #6c757d;
}

.grade-level-progress {
  margin-bottom: 15px;
}

.progress-bar {
  background: #e9ecef;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  height: 100%;
  transition: width 0.3s ease;
}

.grade-level-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.grade-level-stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.grade-level-stats .stat-number {
  font-size: 20px;
  font-weight: 700;
  color: #667eea;
}

.grade-level-stats .stat-label {
  font-size: 11px;
  color: #6c757d;
  text-align: center;
}

/* Reading History */
.history-page {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 1200px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
}

.history-header h1 {
  color: #2c3e50;
  font-size: 28px;
}

.sessions-timeline {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.session-card {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 25px;
  border-left: 4px solid #007bff;
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.session-header h2 {
  color: #2c3e50;
  font-size: 22px;
  margin: 0;
}

.session-date {
  color: #6c757d;
  font-size: 14px;
}

.session-stats {
  display: flex;
  gap: 30px;
  margin-bottom: 20px;
  padding: 15px;
  background: white;
  border-radius: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-label {
  font-size: 12px;
  color: #6c757d;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 20px;
  color: #2c3e50;
  font-weight: bold;
}

.struggled-words {
  margin-bottom: 20px;
}

.struggled-words h4 {
  color: #495057;
  font-size: 14px;
  margin-bottom: 10px;
}

.word-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-tag {
  background: #ffc107;
  color: #333;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}

.session-feedback {
  background: #e8f4f8;
  border-left: 4px solid #17a2b8;
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 6px;
}

.session-feedback h4 {
  color: #0c5460;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.session-feedback p {
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.passage-details {
  margin-top: 15px;
}

.passage-details summary {
  cursor: pointer;
  color: #007bff;
  font-weight: 600;
  padding: 10px;
  background: white;
  border-radius: 6px;
  user-select: none;
}

.passage-details summary:hover {
  background: #e9ecef;
}

.passage-text {
  margin-top: 15px;
  padding: 20px;
  background: white;
  border-radius: 6px;
  line-height: 1.8;
  color: #495057;
}

/* Skills Page Tabs */
.skills-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 0;
}

.tab-btn {
  padding: 12px 24px;
  border: none;
  background: none;
  font-size: 1rem;
  font-weight: 600;
  color: #6c757d;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #495057;
}

.tab-btn.active {
  color: #007bff;
  border-bottom-color: #007bff;
}

.tab-content {
  display: none;
}

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

/* All Skills Tab */
.all-skills-section {
  margin-top: 20px;
}

.all-skills-intro {
  color: #6c757d;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.grade-skills-group {
  margin-bottom: 30px;
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.grade-skills-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  margin: -20px -20px 0 -20px;
  border-bottom: 1px solid #e9ecef;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.grade-skills-header:hover {
  background: #f8f9fa;
}

.grade-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-icon {
  font-size: 0.8rem;
  color: #6c757d;
  transition: transform 0.2s ease;
}

.grade-skills-header h3 {
  margin: 0;
  color: #343a40;
  font-size: 1.1rem;
}

.grade-skills-count {
  font-size: 0.85rem;
  color: #6c757d;
  background: #f8f9fa;
  padding: 4px 10px;
  border-radius: 12px;
}

.grade-skills-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
}

.grade-skills-list.collapsed {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

.grade-skills-group.collapsible {
  padding-bottom: 15px;
}

.grade-skills-group.collapsible:not(.expanded) {
  padding-bottom: 0;
}

.grade-skills-group.collapsible:not(.expanded) .grade-skills-header {
  border-bottom: none;
  margin-bottom: 0;
}

.skill-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-radius: 6px;
  background: #f8f9fa;
}

.skill-list-item.practiced {
  background: #f8f9fa;
}

.skill-list-item.unpracticed {
  background: #fafafa;
  opacity: 0.7;
}

.skill-list-info {
  flex: 1;
  min-width: 0;
}

.skill-list-name {
  font-weight: 600;
  color: #343a40;
  display: block;
  margin-bottom: 2px;
}

.skill-list-description {
  font-size: 0.8rem;
  color: #6c757d;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-list-mastery {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}

.mini-mastery-bar {
  width: 60px;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.mini-mastery-fill {
  height: 100%;
  background: linear-gradient(90deg, #28a745, #20c997);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.mini-mastery-percent {
  font-size: 0.85rem;
  font-weight: 600;
  color: #28a745;
  min-width: 35px;
  text-align: right;
}

.not-practiced-badge {
  font-size: 0.75rem;
  color: #adb5bd;
  background: #e9ecef;
  padding: 4px 8px;
  border-radius: 4px;
}

.assumed-badge {
  font-size: 0.625rem;
  color: #7c3aed;
  background: #ede9fe;
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 0.5rem;
}

/* Responsive adjustments for All Skills tab */
@media (max-width: 768px) {
  .skill-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .skill-list-mastery {
    width: 100%;
  }

  .mini-mastery-bar {
    flex: 1;
  }
}

/* Danger Zone */
.danger-zone {
  margin-top: 40px;
  padding: 20px;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  background: #fff5f5;
}

.danger-zone h3 {
  margin: 0 0 10px 0;
  color: #dc3545;
  font-size: 1rem;
}

.danger-zone p {
  margin: 0 0 15px 0;
  color: #721c24;
  font-size: 0.9rem;
}

.danger-zone .btn-danger {
  background: #dc3545;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.danger-zone .btn-danger:hover {
  background: #c82333;
}
