/* typing-tutor.css */
:root {
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  
  /* Standard touch typing finger color mapping */
  --finger-left-pinky: #ff6b35; /* Orange */
  --finger-left-ring: #f7c548;  /* Yellow */
  --finger-left-middle: #8ac926; /* Green */
  --finger-left-index: #1982c4; /* Blue */
  
  --finger-right-index: #1982c4; /* Blue */
  --finger-right-middle: #8ac926; /* Green */
  --finger-right-ring: #f7c548;  /* Yellow */
  --finger-right-pinky: #ff6b35; /* Orange */
  
  --finger-thumb: #6a4c93; /* Purple */
}

/* Base Layout */
.tutor-body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 16px;
}

/* Header */
.tutor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  z-index: 100;
  border-radius: 0;
  border-top: none;
  border-left: none;
  border-right: none;
  flex-shrink: 0;
  position: sticky;
  top: 0;
}

.tutor-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.tutor-live-stats {
  display: flex;
  gap: 2.5rem;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--primary);
  text-shadow: 0 0 10px rgba(255, 179, 71, 0.3);
}

.timer-select {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px dashed rgba(255, 179, 71, 0.4);
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  padding: 0 0.2rem;
  text-align: center;
  transition: all 0.2s ease;
}
.timer-select:hover, .timer-select:focus {
  border-bottom-color: var(--primary);
}
.timer-select option {
  background-color: #ffffff !important;
  color: #000000 !important;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
}

.stat-value.error-val {
  color: #ef4444;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-back:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Main Layout Grid */
.tutor-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: calc(100vh - 80px);
  gap: 1.5rem;
  padding: 1.5rem;
  box-sizing: border-box;
}

/* Sidebar */
.tutor-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 90px; /* Just below the sticky header */
  max-height: calc(100vh - 120px);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h3 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
}

.progress-bar-container {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  transition: width 0.5s ease;
}

.lesson-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Custom Scrollbar for sidebar */
.lesson-list::-webkit-scrollbar { width: 6px; }
.lesson-list::-webkit-scrollbar-track { background: transparent; }
.lesson-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* Lesson Items */
.lesson-category {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1rem 0 0.5rem 0.5rem;
  font-weight: 700;
}
.lesson-category:first-child {
  margin-top: 0;
}

.lesson-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
  text-align: left;
  font-family: inherit;
  font-size: 0.95rem;
}
.lesson-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}
.lesson-item.active {
  background: rgba(255, 107, 53, 0.1);
  border-color: rgba(255, 107, 53, 0.3);
  color: var(--primary);
}
.lesson-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lesson-title-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lesson-id {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.lesson-stars {
  font-size: 0.9rem;
  letter-spacing: -0.1em;
  color: var(--primary);
}

/* Workspace */
.tutor-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Lesson Header Info */
.lesson-info {
  padding: 0.75rem 1.5rem;
}
.lesson-info .lesson-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.lesson-info h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}
.lesson-instructions {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

/* Hands SVG */
.hands-container {
  display: flex;
  justify-content: center;
  align-items: center;
}
.svg-hand-base { fill: rgba(255, 255, 255, 0.05); stroke: rgba(255,255,255,0.1); stroke-width: 2; transition: all 0.2s; }
.svg-finger { fill: rgba(255, 255, 255, 0.05); stroke: rgba(255,255,255,0.1); stroke-width: 2; transition: all 0.2s; }

/* SVG Finger Highlights */
.svg-finger-l-pinky.highlight { fill: var(--finger-left-pinky); transform: translateY(-5px); }
.svg-finger-l-ring.highlight { fill: var(--finger-left-ring); transform: translateY(-5px); }
.svg-finger-l-middle.highlight { fill: var(--finger-left-middle); transform: translateY(-5px); }
.svg-finger-l-index.highlight { fill: var(--finger-left-index); transform: translateY(-5px); }
.svg-finger-r-index.highlight { fill: var(--finger-right-index); transform: translateY(-5px); }
.svg-finger-r-middle.highlight { fill: var(--finger-right-middle); transform: translateY(-5px); }
.svg-finger-r-ring.highlight { fill: var(--finger-right-ring); transform: translateY(-5px); }
.svg-finger-r-pinky.highlight { fill: var(--finger-right-pinky); transform: translateY(-5px); }

.svg-finger-thumb.highlight { fill: var(--finger-thumb); } /* Let CSS handle rotation/transform via JS classes if needed, or just fill color for now */

/* Typing Area */
.typing-display {
  padding: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  line-height: 1.8;
  white-space: pre-wrap;
  min-height: 150px;
  position: relative;
  letter-spacing: 0.05em;
  display: block;
  text-align: left;
  background: rgba(0, 0, 0, 0.2); /* Make it distinct from the rest */
}

.t-word {
  display: inline-block;
  white-space: pre;
}

.t-char {
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.1s ease;
  position: relative;
}
.t-char.correct {
  color: #10b981; /* Green */
}
.t-char.error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
  animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}
.t-char.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 0 0 var(--primary);
  animation: pulseBg 1.5s infinite;
}

@keyframes pulseBg {
  0%, 100% { background: rgba(255, 255, 255, 0.1); box-shadow: 0 4px 0 0 var(--primary); }
  50% { background: rgba(255, 255, 255, 0.2); box-shadow: 0 4px 0 0 rgba(255, 107, 53, 0.5); }
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Keyboard Area */
.keyboard-container {
  padding: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.virtual-keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 900px;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.kb-key {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  height: 55px;
  min-width: 55px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  user-select: none;
  position: relative;
}

.kb-key.pressed {
  transform: translateY(2px) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
  background: rgba(255, 255, 255, 0.2);
}

.kb-key.wide-1 { width: 85px; }
.kb-key.wide-2 { width: 100px; }
.kb-key.wide-3 { width: 125px; }
.kb-key.spacebar { width: 350px; }

.kb-key span.shift-char {
  font-size: 0.75rem;
  opacity: 0.7;
  position: absolute;
  top: 4px;
  left: 8px;
}
.kb-key span.main-char {
  font-size: 1.1rem;
}

/* Finger Highlights on Keys */
.kb-key.highlight {
  color: #fff;
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 0 20px currentColor;
  transform: translateY(-3px);
  z-index: 2;
}

/* Finger colors apply to the background when highlighted */
.kb-key.finger-l-pinky.highlight { background: var(--finger-left-pinky); color: #fff;}
.kb-key.finger-l-ring.highlight { background: var(--finger-left-ring); color: #000; }
.kb-key.finger-l-middle.highlight { background: var(--finger-left-middle); color: #000; }
.kb-key.finger-l-index.highlight { background: var(--finger-left-index); color: #fff; }
.kb-key.finger-r-index.highlight { background: var(--finger-right-index); color: #fff; }
.kb-key.finger-r-middle.highlight { background: var(--finger-right-middle); color: #000; }
.kb-key.finger-r-ring.highlight { background: var(--finger-right-ring); color: #000; }
.kb-key.finger-r-pinky.highlight { background: var(--finger-right-pinky); color: #fff; }
.kb-key.finger-thumb.highlight { background: var(--finger-thumb); color: #fff; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
  backdrop-filter: blur(5px);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  padding: 3rem;
  text-align: center;
  max-width: 450px;
  width: 90%;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-content h2 {
  margin: 0 0 1rem 0;
  font-size: 2rem;
  color: var(--text-primary);
}

.modal-stars {
  font-size: 3rem;
  margin-bottom: 2rem;
  letter-spacing: 5px;
  text-shadow: 0 0 20px rgba(255, 179, 71, 0.5);
}

.modal-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  text-align: left;
  background: rgba(0,0,0,0.2);
  padding: 1.5rem;
  border-radius: 12px;
}
.m-stat {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  color: var(--text-secondary);
}
.m-stat strong {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.modal-actions .btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 1rem;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}
.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.2);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .tutor-layout {
    grid-template-columns: 240px 1fr;
    gap: 1rem;
    padding: 1rem;
  }
  .typing-display {
    font-size: 2rem;
  }
  .kb-key {
    min-width: 45px;
    height: 45px;
    font-size: 0.9rem;
  }
  .kb-key.wide-1 { width: 70px; }
  .kb-key.wide-2 { width: 85px; }
  .kb-key.wide-3 { width: 105px; }
  .kb-key.spacebar { width: 280px; }
}

@media (max-width: 768px) {
  .tutor-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
    height: auto;
  }
  .tutor-sidebar {
    height: 300px;
  }
  .tutor-workspace {
    overflow: visible;
  }
  .typing-display {
    font-size: 1.5rem;
    padding: 1rem;
  }
  .tutor-live-stats {
    gap: 1rem;
  }
  .stat-value {
    font-size: 1.1rem;
  }
  .keyboard-container {
    display: none; /* Hide keyboard on small screens as it takes too much space */
  }
}

/* Hidden Input for Mobile Support */
.hidden-input {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  opacity: 0;
  z-index: -1;
  border: none;
  padding: 0;
  margin: 0;
}
