/* Task Widget Styles */
:root {
  --primary-color: #4f46e5;
  --secondary-color: #10b981;
  --tertiary-color: #6b7280;
  --bg-color: #ffffff;
  --bg-dark: #1e293b;
  --text-color: #0f172a;
  --text-light: #64748b;
  --border-color: #e2e8f0;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --code-bg: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f1f5f9;
}

.task-widget {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-color);
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.task-widget__header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-widget__title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.task-widget__difficulty {
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.task-widget__description {
  padding: 20px 24px;
  color: var(--text-color);
  line-height: 1.6;
  border-bottom: 1px solid var(--border-color);
}

.task-widget__main {
  display: grid;
  grid-template-columns: 1fr 8px 1fr;
  gap: 0;
  min-height: 500px;
  flex: 1 1 auto;
}

@media (max-width: 760px) {
  .task-widget__main {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .task-widget__vresizer {
    display: none;
  }

  /* В один столбец высоты не хватает — задаём её блокам явно,
     иначе редактор схлопывается и текст кода обрезается */
  .task-widget__editor-section {
    min-height: 360px;
  }

  .task-widget__output-section {
    min-height: 280px;
  }
}

.task-widget__editor-section,
.task-widget__output-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.task-widget__tabs {
  display: flex;
  gap: 0;
  background: var(--code-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
}

.tab {
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab:hover {
  color: var(--text-color);
  background: rgba(0, 0, 0, 0.02);
}

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

.task-widget__editor {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.code-editor {
  width: 100%;
  height: 100%;
  padding: 16px;
  border: none;
  outline: none;
  font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  background: var(--code-bg);
  color: var(--text-color);
  resize: none;
  tab-size: 2;
}

.task-widget__actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--code-bg);
  border-top: 1px solid var(--border-color);
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary:hover {
  background: #4338ca;
}

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

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

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

.btn-tertiary:hover {
  background: #4b5563;
}

.task-widget__panel {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.task-widget__panel.active {
  display: block;
}

.console-output {
  font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.console-line {
  padding: 4px 8px;
  border-left: 3px solid transparent;
  margin: 2px 0;
  word-wrap: break-word;
}

.console-line.log {
  border-left-color: #64748b;
  color: #334155;
}

.console-line.info {
  border-left-color: #3b82f6;
  color: #1e40af;
  background: #eff6ff;
}

.console-line.warn {
  border-left-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}

.console-line.error {
  border-left-color: #ef4444;
  color: #991b1b;
  background: #fef2f2;
}

.tests-output {
  font-size: 14px;
}

.test-item {
  padding: 12px;
  margin: 8px 0;
  border-radius: 6px;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 12px;
}

.test-item.pass {
  background: #f0fdf4;
  border-left-color: var(--success-color);
}

.test-item.fail {
  background: #fef2f2;
  border-left-color: var(--error-color);
}

.test-icon {
  font-size: 18px;
  font-weight: bold;
}

.test-item.pass .test-icon {
  color: var(--success-color);
}

.test-item.fail .test-icon {
  color: var(--error-color);
}

.test-description {
  flex: 1;
  font-weight: 500;
}

.hints-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint-item {
  padding: 12px;
  background: #fffbeb;
  border-left: 4px solid var(--warning-color);
  border-radius: 6px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.hint-icon {
  font-size: 18px;
  color: var(--warning-color);
  flex-shrink: 0;
}

.hint-text {
  flex: 1;
  color: #78350f;
  line-height: 1.6;
}

.task-widget__preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-light);
  font-style: italic;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-light);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Success/Error messages */
.message {
  padding: 12px 16px;
  border-radius: 6px;
  margin: 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.message.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #86efac;
}

.message.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.message-icon {
  font-size: 20px;
}

/* File tabs for multi-file editor */
.file-tabs {
  display: flex;
  gap: 4px;
  background: var(--code-bg);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.file-tab {
  padding: 6px 12px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s;
}

.file-tab:hover {
  background: rgba(0, 0, 0, 0.05);
}

.file-tab.active {
  background: white;
  border-color: var(--border-color);
  color: var(--text-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .task-widget__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .task-widget__actions {
    flex-wrap: wrap;
  }
  
  .btn {
    flex: 1;
    min-width: 100px;
  }
}

/* ── Приветствие, пока задание не выбрано ─────────────────────────────────── */
.task-widget.is-empty .task-widget__main,
.task-widget.is-empty .task-widget__resizer {
  display: none;
}

.task-widget__welcome {
  max-width: 720px;
}

.task-widget__welcome-lead {
  margin: 0 0 12px;
  font-size: 16px;
}

.task-widget__welcome-steps {
  margin: 0 0 12px;
  padding-left: 22px;
  line-height: 1.7;
}

.task-widget__welcome-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-light);
}

/* ── Перегородка между кодом и выводом ────────────────────────────────────── */
.task-widget__vresizer {
  position: relative;
  width: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--code-bg);
  box-shadow: inset 1px 0 0 var(--border-color), inset -1px 0 0 var(--border-color);
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  transition: background 0.15s;
}

.task-widget__vresizer:hover,
.task-widget__vresizer.is-dragging {
  background: #eef2ff;
  box-shadow: inset 1px 0 0 #c7d2fe, inset -1px 0 0 #c7d2fe;
}

.task-widget__vresizer-grip {
  width: 4px;
  height: 40px;
  border-radius: 2px;
  background: #94a3b8;
  transition: background 0.15s, height 0.15s;
}

.task-widget__vresizer:hover .task-widget__vresizer-grip,
.task-widget__vresizer.is-dragging .task-widget__vresizer-grip {
  background: var(--primary-color);
  height: 64px;
}

