/* ============================================================
   LERNWERK - Modern Learning Platform Styles
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #475569;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f1f5f9;
  --bg-white: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ============ HEADER ============ */
.header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-brand .icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-nav a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.header-nav a:hover, .header-nav a.active {
  color: white;
  background: rgba(255,255,255,0.1);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: #94a3b8;
}

.btn-logout {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* ============ LOGIN ============ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-card {
  background: white;
  padding: 48px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 0.875rem;
}

/* ============ FORMS ============ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-error {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-top: 4px;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

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

.btn-success:hover {
  background: #15803d;
}

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ LAYOUT ============ */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-wide {
  max-width: 1400px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

/* ============ GRID ============ */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ============ STAT CARDS ============ */
.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ============ SESSION CARDS ============ */
.session-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border-left: 4px solid var(--primary);
}

.session-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.session-card .sc-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.session-card .sc-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.session-card .sc-theme {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ============ PROGRESS BAR ============ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width 0.3s ease;
}

.progress-bar .progress-fill.green { background: var(--success); }
.progress-bar .progress-fill.yellow { background: var(--warning); }

/* ============ TABLE ============ */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
}

tr:hover td {
  background: #f8fafc;
}

/* ============ BADGES ============ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }

/* ============ TRAFFIC LIGHT ============ */
.traffic-light {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.traffic-light.green { background: var(--success); box-shadow: 0 0 6px rgba(22,163,74,0.4); }
.traffic-light.yellow { background: var(--warning); box-shadow: 0 0 6px rgba(217,119,6,0.4); }
.traffic-light.red { background: var(--danger); box-shadow: 0 0 6px rgba(220,38,38,0.4); }

/* ============ TASK AREA ============ */
.task-container {
  max-width: 700px;
  margin: 0 auto;
}

.task-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.task-header {
  padding: 16px 24px;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-header .task-module {
  font-size: 0.8125rem;
  opacity: 0.7;
}

.task-header .task-progress {
  font-size: 0.8125rem;
}

.task-body {
  padding: 32px 24px;
}

.task-question {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.5;
}

.task-difficulty {
  display: flex;
  gap: 3px;
  margin-bottom: 16px;
}

.task-difficulty .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.task-difficulty .dot.active { background: var(--primary); }

.task-points {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.task-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

/* ============ TASK OPTIONS ============ */
.option-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-item {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
}

.option-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-item.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.option-item.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
}

.option-radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.option-item.selected .option-radio {
  border-color: var(--primary);
}

.option-item.selected .option-radio::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.option-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.option-item.selected .option-checkbox {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* ============ ORDERING TASK ============ */
.ordering-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ordering-item {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
  transition: all 0.2s;
}

.ordering-item:active { cursor: grabbing; }

.ordering-item .order-handle {
  color: var(--text-light);
  font-size: 1.2rem;
}

.ordering-item .order-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.ordering-item.dragging {
  opacity: 0.5;
  border-color: var(--primary);
}

.ordering-item.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ============ MATCHING TASK ============ */
.matching-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.match-left {
  background: var(--primary-light);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  text-align: right;
}

.match-arrow {
  color: var(--text-light);
  font-size: 1.2rem;
}

.match-select {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  background: white;
  cursor: pointer;
}

.match-select:focus {
  border-color: var(--primary);
  outline: none;
}

/* ============ HINTS ============ */
.hint-area {
  margin-top: 20px;
}

.hint-btn {
  color: var(--primary);
  background: none;
  border: 1px dashed var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8125rem;
  transition: all 0.2s;
}

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

.hint-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 10px;
  font-size: 0.875rem;
  color: #92400e;
}

/* ============ FEEDBACK ============ */
.feedback {
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-top: 20px;
  font-weight: 500;
}

.feedback.correct {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #bbf7d0;
}

.feedback.wrong {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* ============ RANKING / BEAMER VIEW ============ */
.ranking-page {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  min-height: 100vh;
  color: white;
  padding: 40px;
}

.ranking-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 8px;
}

.ranking-subtitle {
  text-align: center;
  color: #64748b;
  margin-bottom: 40px;
}

.ranking-list {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-lg);
  transition: all 0.3s;
}

.ranking-row:nth-child(1) {
  background: rgba(234,179,8,0.15);
  border: 1px solid rgba(234,179,8,0.3);
}

.ranking-row:nth-child(2) {
  background: rgba(148,163,184,0.15);
  border: 1px solid rgba(148,163,184,0.3);
}

.ranking-row:nth-child(3) {
  background: rgba(180,83,9,0.15);
  border: 1px solid rgba(180,83,9,0.2);
}

.ranking-pos {
  font-size: 1.5rem;
  font-weight: 700;
  width: 40px;
  text-align: center;
}

.ranking-pos.gold { color: #eab308; }
.ranking-pos.silver { color: #94a3b8; }
.ranking-pos.bronze { color: #b45309; }

.ranking-name {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 500;
}

.ranking-points {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.ranking-bar {
  width: 200px;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.ranking-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.5s ease;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============ MISC ============ */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.8125rem; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.w-full { width: 100%; }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9375rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  font-size: 0.875rem;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ COMPLETED SCREEN ============ */
.completed-screen {
  text-align: center;
  padding: 60px 24px;
}

.completed-screen .big-check {
  width: 80px;
  height: 80px;
  background: var(--success-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 2.5rem;
  color: var(--success);
}

.completed-screen h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.completed-screen p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.completed-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 32px;
}

.completed-stats .cs-item {
  text-align: center;
}

.completed-stats .cs-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

.completed-stats .cs-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Stats Grid (used in support detail) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Support / Stuetzlehrer */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.card-hover:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
  transition: all 0.15s ease;
}
.stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.stat-mini {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8125rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-cards { grid-template-columns: 1fr; }
}
