/**
 * SQL Easy - Lesson Page Styles
 * Modern, clean styling for interactive SQL lessons - Light Theme
 */

/* CSS Custom Properties */
:root {
  --primary-color: #743cb5;
  --primary-hover: #5a2d8a;
  --primary-light: rgba(116, 60, 181, 0.1);
  
  --success-color: #28a745;
  --success-light: #d4edda;
  --error-color: #dc3545;
  --error-light: #f8d7da;
  
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  
  --bg-white: #ffffff;
  --bg-light: #f8f9fa;
  --bg-subtle: #f1f3f4;
  
  --border-color: #dee2e6;
  --border-light: #e9ecef;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --font-family-code: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  
  --completion-color: #28a745;
}

/* Keep existing body styling but improve it */
body {
  background-color: var(--bg-white);
  border-top: 5px solid var(--primary-color);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
}

/* Container */
.lesson-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header improvements */
header {
  background: var(--bg-white);
  padding: 2rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.lesson-header h1 {
  color: var(--primary-color);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.lesson-progress {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
}

/* Navigation improvements */
#links-subheader {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 0;
  flex-wrap: wrap;
  background: var(--bg-white);
}

/* Better button styling */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  border-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #4a2370);
  border-color: var(--primary-hover);
  color: white;
}

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

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-color);
  color: var(--text-primary);
}

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

.btn-success:hover {
  background: #218838;
  border-color: #1e7e34;
  color: white;
}

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

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* Layout - keep it simple with flexbox instead of complex grid */
.lesson-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  background: var(--bg-white);
  padding: 1rem 0;
}

/* Sidebar menu */
.lesson-menu {
  flex: 0 0 280px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 2rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.lesson-menu h3 {
  color: var(--primary-color);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-light);
}

.menu-item {
  margin-bottom: 0.5rem;
}

.menu-item a {
  display: block;
  padding: 0.75rem;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.menu-item a:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
  text-decoration: none;
}

.menu-item strong a {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  border-color: var(--primary-color);
}

/* Main content */
.lesson-content {
  flex: 1;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Lesson title section */
.lesson-title-section {
  background: var(--bg-white);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-light);
}

#lesson-name {
  color: var(--primary-color);
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.lesson-type {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Lesson content */
#prompt {
  padding: 2rem;
  font-size: 1.1rem;
  line-height: 1.7;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

#prompt code {
  background: var(--bg-subtle);
  color: var(--primary-color);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-family-code);
  font-size: 0.9em;
  font-weight: 600;
  border: 1px solid var(--border-light);
}

#prompt em {
  color: var(--primary-color);
  font-style: normal;
  font-weight: 600;
}

#prompt strong {
  color: var(--primary-color);
  font-weight: 600;
}

/* SQL workspace */
.sql-workspace {
  padding: 2rem;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-light);
}

#sql-header {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.sql-input-wrapper {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

#sql-input {
  flex: 1;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-family-code);
  font-size: 1rem;
  line-height: 1.4;
  background: var(--bg-white);
  color: var(--text-primary);
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#sql-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

#sql-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

#sql-link {
  background: var(--primary-color);
  color: white;
  border: 2px solid var(--primary-color);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sql-link:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: white;
  text-decoration: none;
}

#sql-link:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Results section */
.results-section {
  padding: 2rem;
  background: var(--bg-white);
}

.results-container {
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.current-tables-container {
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.results-container h4,
.current-tables-container h4,
.expected-results-container h4 {
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
}

/* Table styling */
.table-responsive-xl {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  font-size: 0.9rem;
  margin: 0;
}

th {
  background: var(--primary-color) !important;
  color: white !important;
  padding: 0.75rem !important;
  font-weight: 600;
  text-align: left;
  border: none !important;
}

td {
  padding: 0.75rem !important;
  border-bottom: 1px solid var(--border-light) !important;
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  background: var(--bg-white);
}

tbody tr:hover {
  background: var(--bg-subtle);
}

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

.table-name {
  font-style: italic;
  color: var(--primary-color);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Feedback messages */
.feedback-section {
  padding: 1rem 2rem 2rem 2rem;
  background: var(--bg-white);
}

#answer-correct,
#answer-wrong {
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  margin-bottom: 1rem;
  border: 1px solid;
  display: none;
}

#answer-correct {
  background: var(--success-light);
  border-color: var(--success-color);
  color: #155724;
}

#answer-wrong {
  background: var(--error-light);
  border-color: var(--error-color);
  color: #721c24;
}

.expected-results-container {
  margin-top: 1.5rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: none;
}

.expected-results-container h4 {
  color: #856404;
}

/* Mobile responsive */
@media (max-width: 992px) {
  .lesson-layout {
    flex-direction: column;
    gap: 1rem;
  }
  
  .lesson-menu {
    flex: none;
    position: static;
    max-height: none;
  }
  
  .results-section {
    padding: 1rem;
  }
  
  .sql-input-wrapper {
    flex-direction: column;
  }
  
  #sql-link {
    width: 100%;
  }
}

@media (max-width: 768px) {
  #links-subheader {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .btn-sm {
    width: auto;
    align-self: center;
  }
  
  .lesson-content,
  .lesson-menu {
    margin: 0 0.5rem;
  }
  
  #lesson-name,
  #prompt,
  .sql-workspace,
  .results-section,
  .feedback-section {
    padding: 1rem;
  }
  
  .menu-hidden-for-mobile {
    display: none;
  }
  
  #menu-link {
    display: block !important;
  }
  
  table {
    font-size: 0.8rem;
  }
  
  th, td {
    padding: 0.5rem !important;
  }
}

@media (min-width: 769px) {
  #menu-link {
    display: none;
  }
}

/* Focus improvements for accessibility */
.btn:focus,
#sql-input:focus,
.menu-item a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Loading animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn:disabled {
  animation: pulse 1.5s infinite;
}

/* Smooth transitions */
#answer-correct,
#answer-wrong {
  animation: fadeIn 0.3s ease-out;
}

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

/* Progress tracking styles */
.completion-indicator {
  color: var(--success-color);
  font-weight: bold;
  margin-right: 0.5rem;
  font-size: 0.9em;
  display: inline;
}

.menu-item.completed {
  background-color: rgba(40, 167, 69, 0.05);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success-color);
  padding-left: 0.5rem;
  margin-left: -0.5rem;
}

.menu-item.completed a {
  color: var(--text-primary);
  font-weight: 500;
}

/* Current lesson that's also completed should keep white text */
.menu-item.completed strong a {
  color: white !important;
  background: var(--primary-color);
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 0.25rem 0;
}

.lesson-controls {
  margin-top: 1rem;
}

.lesson-controls .btn {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
}

/* Reset lesson button styling */
#reset-lesson-btn {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

#reset-lesson-btn:hover {
  background-color: var(--error-light);
  border-color: var(--error-color);
  color: var(--error-color);
}