/* Math Worksheet Generator - Web UI Styles */

/* Color Palette */
:root {
  --primary-color: #000000;
  --secondary-color: #6c757d;
  --light-gray: #e9ecef;
  --border-color: #dee2e6;
  --white: #ffffff;
  --dark-gray: #343a40;
  --light-background: #f8f9fa;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--light-background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 2rem;
}

.navbar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 600;
}

.container-fluid {
  padding: 0 15px;
}

/* ============================================================================
   Step Indicator
   ============================================================================ */

.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.4;
  transition: all 0.3s ease;
}

.step.active {
  opacity: 1;
}

.step-number {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--light-gray);
  color: var(--secondary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  transition: all 0.3s ease;
}

.step.active .step-number {
  background: var(--primary-color);
  color: white;
}

.step-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--secondary-color);
  white-space: nowrap;
}

.step.active .step-label {
  color: var(--primary-color);
}

.step-connector {
  width: 80px;
  height: 2px;
  background: var(--border-color);
  margin: 0 1.5rem 2rem 1.5rem;
  transition: background 0.3s ease;
}

/* ============================================================================
   Step Content
   ============================================================================ */

.step-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.step-content.active {
  display: block;
}

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

/* ============================================================================
   Cards
   ============================================================================ */

.card {
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
  border-radius: 8px 8px 0 0 !important;
  padding: 1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  background-color: white !important;
  border-bottom: 2px solid var(--light-gray);
  color: var(--primary-color) !important;
}

.card-body {
  padding: 1.5rem;
}

/* ============================================================================
   Task Cards
   ============================================================================ */

.task-card {
  border-left: 3px solid var(--primary-color);
  background: white;
}

.task-card .form-label {
  font-weight: 500;
  color: var(--dark-gray);
  margin-bottom: 0.5rem;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Dark Button (Primary) */
.btn-dark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.btn-dark:hover {
  background-color: #1a1a1a;
  border-color: #1a1a1a;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Outline Dark Button (Secondary) */
.btn-outline-dark {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background-color: transparent;
}

.btn-outline-dark:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Outline Secondary Button */
.btn-outline-secondary {
  border-color: var(--secondary-color);
  color: var(--secondary-color);
  background-color: transparent;
}

.btn-outline-secondary:hover {
  background-color: var(--secondary-color);
  color: white;
  transform: translateY(-1px);
}

/* Small Buttons */
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================================================
   Form Controls
   ============================================================================ */

.form-control,
.form-select {
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.1);
}

.form-control-sm,
.form-select-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
}

.form-label {
  font-weight: 500;
  color: var(--dark-gray);
  margin-bottom: 0.5rem;
}

.form-check-input {
  border-color: var(--border-color);
}

.form-check-input:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.form-check-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   Preview Section
   ============================================================================ */

#previewContent {
  font-size: 1rem;
  line-height: 1.8;
  color: #333;
}

.preview-info {
  padding: 1rem;
  background-color: var(--light-gray);
  border-radius: 6px;
  border-left: 3px solid var(--primary-color);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.preview-item {
  padding: 0.75rem;
  background-color: var(--light-background);
  border-radius: 4px;
  border-left: 2px solid var(--border-color);
  word-break: break-word;
  margin-bottom: 0.5rem;
}

.preview-item strong {
  color: var(--primary-color);
  margin-right: 0.5rem;
  font-weight: 700;
}

/* ============================================================================
   Alerts
   ============================================================================ */

.alert {
  border-radius: 6px;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.alert-danger {
  background-color: #f8d7da;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  border-left: 4px solid #198754;
}

.alert-warning {
  background-color: #fff3cd;
  color: #664d03;
  border-left: 4px solid #ffc107;
}

/* ============================================================================
   Spinner
   ============================================================================ */

.spinner-border-sm {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 0.25em;
  border-color: var(--primary-color);
}

.spinner-border-sm .spinner-border {
  border-color: var(--primary-color) !important;
}

.text-muted {
  color: var(--secondary-color) !important;
}

/* ============================================================================
   Math Rendering (MathJax)
   ============================================================================ */

.mjx-container {
  font-size: 1.1em;
  margin: 0.5em 0;
}

/* ============================================================================
   Typography
   ============================================================================ */

h5 {
  font-weight: 600;
  color: #222;
}

h6 {
  font-weight: 600;
  color: #333;
}

strong {
  font-weight: 600;
}

.small {
  font-size: 0.875rem;
}

/* ============================================================================
   Modal Styles
   ============================================================================ */

.modal-content {
  border-radius: 8px;
  border: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  background-color: var(--primary-color);
  color: white;
  border-radius: 8px 8px 0 0;
  border: none;
  font-weight: 600;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
}

.modal-body {
  padding: 1.5rem;
  background-color: var(--light-background);
}

#pdfFrame {
  border-radius: 4px;
}

.modal-footer {
  background-color: var(--light-background);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: 0 0 8px 8px;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.text-center {
  text-align: center;
}

.d-none {
  display: none !important;
}

.d-grid {
  display: grid;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 1rem;
}

.mb-1 {
  margin-bottom: 0.25rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 1rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 1rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.mt-5 {
  margin-top: 3rem;
}

.ms-2 {
  margin-left: 0.5rem;
}

.me-2 {
  margin-right: 0.5rem;
}

.w-100 {
  width: 100%;
}

.p-3 {
  padding: 1rem;
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ============================================================================
   Category Sections (Task Type Grouping)
   ============================================================================ */

.category-section {
  margin-bottom: 12px;
  padding: 8px;
  background: #ffffff;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.category-toggle {
  transition: background-color 0.2s ease;
}

.category-toggle:hover {
  background-color: #dee2e6 !important;
}

.category-items {
  transition: all 0.3s ease;
}

.draggable-task {
  transition: all 0.2s ease;
}

.draggable-task:hover {
  background-color: #e7f1ff !important;
  border-color: #0d6efd !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   Responsive Layout
   ============================================================================ */

@media (max-width: 992px) {
  .step-indicator {
    flex-direction: column;
    padding: 1rem;
  }

  .step-connector {
    width: 2px;
    height: 30px;
    margin: 0.5rem 0;
  }

  .col-lg-3,
  .col-lg-8,
  .col-lg-9 {
    margin-bottom: 1rem;
  }

  .card {
    margin-bottom: 1rem;
  }

  #previewContent {
    max-height: 600px;
  }

  .sticky-top {
    position: static;
  }
}

@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1.2rem;
  }

  .card-header {
    padding: 0.75rem;
  }

  .card-body {
    padding: 1rem;
  }

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

  .form-label {
    font-size: 0.875rem;
  }

  #previewContent {
    font-size: 0.95rem;
  }

  .preview-item {
    padding: 0.5rem;
    font-size: 0.9rem;
  }

  .step-indicator {
    padding: 0.75rem;
  }

  .step-label {
    font-size: 0.8rem;
  }

  .step-number {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

/* ============================================================================
   Icons
   ============================================================================ */

.fas,
.far {
  font-size: 0.9em;
}

/* ============================================================================
   Accessibility
   ============================================================================ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   Message Container (Redesign)
   ============================================================================ */

#messageContainer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#messageContainer .alert {
  margin: 0;
  animation: slideInDown 0.3s ease;
}

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

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

.alert.removing {
  animation: slideOutUp 0.3s ease;
}

/* ============================================================================
   Task Cards - Redesign (Kompakt)
   ============================================================================ */

.task-card {
  position: relative;
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 3px solid var(--primary-color);
  transition: all 0.2s ease;
}

/* Task Card Actions (Up/Down/Close Buttons) */
.task-card-actions {
  display: flex;
  gap: 4px;
  align-items: left;
  flex-shrink: 0;
}

.task-card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* Close Button (rotes X oben rechts) */
.task-card-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background-color: transparent;
  color: #dc3545;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.task-card-close:hover {
  background-color: rgba(220, 53, 69, 0.1);
  color: #c82333;
}

.task-card-close:active {
  transform: scale(0.95);
}

/* Move Up/Down Buttons */
.btn-move-up,
.btn-move-down {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  background-color: transparent;
  color: #999;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.65rem;
}

.btn-move-up:hover:not(:disabled),
.btn-move-down:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background-color: transparent;
}

.btn-move-up:active:not(:disabled),
.btn-move-down:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-move-up:disabled,
.btn-move-down:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Task Card Header */
.task-card-header {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary-color);
  margin-bottom: 12px;
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.task-card-header span {
  flex: 1 1 auto;
  min-width: 0;
}

.task-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
  margin-right: -4px;
}

/* Task Card Content Grid */
.task-card-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: flex-start;
}

.task-card-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}

/* Section Label */
.section-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #666;
  white-space: nowrap;
}

/* Task Card Sections */
.task-input-section,
.columns-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 0 1 auto;
}


.difficulty-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 0 1 auto;
  margin-left: auto;
}

/* ============================================================================
   Difficulty Buttons (mit Icons + Farben)
   ============================================================================ */

.difficulty-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  margin-left: auto;
}

.btn-difficulty {
  min-width: 44px;
  height: 28px;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  background-color: white;
  color: #666;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-direction: row;
  gap: 1px;
  flex-shrink: 0;
}

.btn-difficulty:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Easy - Green */
.btn-difficulty[data-difficulty="easy"] {
  border-color: #28a745;
}

.btn-difficulty[data-difficulty="easy"].active {
  background-color: #d4edda;
  color: #155724;
  border-color: #28a745;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

/* Medium - Yellow */
.btn-difficulty[data-difficulty="medium"] {
  border-color: #ffc107;
}

.btn-difficulty[data-difficulty="medium"].active {
  background-color: #fff3cd;
  color: #664d03;
  border-color: #ffc107;
  box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
}

/* Hard - Red */
.btn-difficulty[data-difficulty="hard"] {
  border-color: #dc3545;
}

.btn-difficulty[data-difficulty="hard"].active {
  background-color: #f8d7da;
  color: #721c24;
  border-color: #dc3545;
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.btn-difficulty i {
  font-size: 0.85rem;
  line-height: 1;
}

/* ============================================================================
   Count Input (rechts von Difficulty)
   ============================================================================ */

.task-card-input {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 60px;
  flex: 0 1 auto;
}

.task-card-input input {
  width: 60px;
  height: 36px;
  border: 1.5px solid #dee2e6;
  border-radius: 4px;
  padding: 4px;
  font-size: 0.8rem;
  text-align: center;
  transition: all 0.2s ease;
}

.task-card-input input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   Columns Selector (Word-style)
   ============================================================================ */

.columns-selector {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

.btn-columns {
  min-width: 40px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  background-color: white;
  color: #666;
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-columns i {
  font-size: 0.75rem;
}

.btn-columns:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background-color: transparent;
}

.btn-columns.active {
  background-color: transparent;
  color: var(--primary-color);
  border-color: var(--primary-color);
  border-width: 2px;
  font-weight: 600;
}

/* ============================================================================
   TaskList Drag & Drop
   ============================================================================ */

#taskList {
  border: 2px dashed #007bff;
  border-radius: 8px;
  padding: 12px !important;
  background-color: #f0f8ff;
  transition: all 0.2s ease;
  min-height: 300px;
}

#taskList.drag-over {
  background-color: #e3f2fd;
  border-color: #1976d2;
}

/* ============================================================================
   Drop-Zones (für Task-Reordering) - Versteckt
   ============================================================================ */

.drop-zone {
  display: none;
}

/* ============================================================================
   Responsive Task Card
   ============================================================================ */

@media (max-width: 768px) {
  .task-card {
    padding: 10px;
  }

  .task-card-header {
    font-size: 0.9rem;
    padding-right: 28px;
  }

  .btn-difficulty {
    width: 34px;
    height: 34px;
  }

  .task-card-input input {
    height: 30px;
  }

  .btn-columns {
    padding: 5px 6px;
    font-size: 0.7rem;
  }

  .task-card-row {
    gap: 6px;
  }
}

@media (max-width: 576px) {
  .task-card {
    padding: 8px;
  }

  .task-card-header {
    font-size: 0.85rem;
  }

  .difficulty-buttons {
    gap: 4px;
  }

  .btn-difficulty {
    width: 32px;
    height: 32px;
    font-size: 0.7rem;
  }

  .btn-columns {
    padding: 4px 5px;
    font-size: 0.65rem;
    flex: 0 1 calc(50% - 3px);
  }

  .task-card-input {
    min-width: 55px;
  }

  .task-card-input input {
    height: 28px;
    font-size: 0.8rem;
  }

  .task-card-row {
    gap: 4px;
  }
}
