/* Practice System Styles */
:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  --border: #dee2e6;
  --error-bg: #fff3cd;
  --correct-bg: #d1e7dd;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Navbar */
.navbar {
  background: var(--card-bg);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

/* Page Header */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
}

.subtitle {
  color: var(--text-muted);
  margin: 0;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-footer {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* Prompt Card */
.prompt-buttons {
  display: flex;
  gap: 0.5rem;
}

.prompt-text {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 0.5rem 0;
}

.prompt-text .prompt-lv {
  color: var(--primary);
  font-weight: 600;
}

.prompt-text .prompt-en {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 400;
}

.prompt-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.prompt-source {
  font-size: 0.75rem;
  color: var(--primary);
  margin: 0.5rem 0 0 0;
  padding: 0.25rem 0.5rem;
  background: #e7f3ff;
  border-radius: 4px;
  display: inline-block;
}

/* Writing Area */
.writing-textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 200px;
  transition: border-color 0.2s;
}

.writing-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.word-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

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

.btn-secondary:hover {
  background: #c5ccd3;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Results Section */
.score-badge {
  background: var(--success);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
}

.score-badge.low {
  background: var(--danger);
}

.score-badge.medium {
  background: var(--warning);
  color: var(--text);
}

/* Comparison */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.comparison-column h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.75rem 0;
}

.text-display {
  padding: 1rem;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.text-display.original {
  background: #f8f9fa;
  border: 1px solid var(--border);
}

.text-display.corrected {
  background: var(--correct-bg);
  border: 1px solid var(--success);
}

/* Error Highlighting */
.error-text {
  background: #ffcccc;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  text-decoration: line-through;
  color: var(--danger);
}

.correction-text {
  background: #ccffcc;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  font-weight: 500;
  color: var(--success);
}

/* Errors List */
.errors-section h3,
.feedback-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 1rem 0;
}

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

.errors-list li {
  padding: 0.75rem 1rem;
  background: var(--error-bg);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.error-original {
  font-weight: 500;
}

.error-arrow {
  color: var(--text-muted);
}

.error-correction {
  color: var(--success);
  font-weight: 500;
}

.error-explanation {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.error-type {
  font-size: 0.75rem;
  background: var(--text-muted);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  display: inline-block;
  margin-top: 0.25rem;
}

/* Feedback */
.feedback-text {
  padding: 1rem;
  background: #e7f3ff;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  margin: 0;
}

/* CEFR Impact */
.cefr-impact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  margin-top: 1.5rem;
}

.cefr-badge {
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-weight: 600;
}

.cefr-change {
  font-size: 0.875rem;
  color: var(--success);
}

.cefr-change.negative {
  color: var(--danger);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ==========================================
   MOBILE RESPONSIVE STYLES
   ========================================== */

/* Mobile Navbar */
@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }

  .nav-brand {
    font-size: 1.1rem;
  }

  .nav-links {
    gap: 0.75rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .nav-links a {
    padding: 0.25rem 0.5rem;
  }
}

/* Mobile Container */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }
}

/* Mobile Cards */
@media (max-width: 768px) {
  .card {
    padding: 1rem;
    border-radius: 8px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-footer {
    flex-direction: column;
  }

  .card-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Mobile Buttons */
@media (max-width: 768px) {
  .btn {
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    width: 100%;
    justify-content: center;
  }

  .btn-sm {
    padding: 0.625rem 1rem;
  }

  .prompt-buttons {
    flex-direction: column;
    width: 100%;
  }

  .prompt-buttons .btn {
    width: 100%;
  }
}

/* Mobile Writing */
@media (max-width: 768px) {
  .writing-textarea {
    min-height: 150px;
    font-size: 16px; /* Prevents iOS zoom */
  }

  .prompt-text {
    font-size: 1.1rem;
  }
}

/* Mobile Practice Modal */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .modal h3 {
    font-size: 1.25rem;
  }

  .exercise-question {
    font-size: 1.1rem !important;
  }

  .mc-options {
    gap: 0.75rem !important;
  }

  .mc-option {
    padding: 1rem !important;
    font-size: 1rem !important;
    min-height: 48px;
  }

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

/* Mobile Tables */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    white-space: nowrap;
    padding: 0.5rem;
    font-size: 0.875rem;
  }
}

/* Mobile Vocabulary Grid */
@media (max-width: 768px) {
  .vocab-grid {
    grid-template-columns: 1fr !important;
  }

  .vocab-item {
    padding: 0.75rem;
  }
}

/* Touch-friendly tap targets */
@media (max-width: 768px) {
  a, button, .mc-option, .clickable {
    min-height: 44px;
    min-width: 44px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 0.875rem;
  }
}

/* Mobile Score/Stats */
@media (max-width: 768px) {
  .score-badge {
    font-size: 1rem;
    padding: 0.625rem 1.25rem;
  }

  .cefr-impact {
    flex-direction: column;
    text-align: center;
  }
}

/* Small phones */
@media (max-width: 375px) {
  .container {
    padding: 0.75rem;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  .nav-links {
    gap: 0.5rem;
    font-size: 0.8rem;
  }

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