/* ================================================================
   TechTools — 口算题生成器 (Math Drill Generator) Styles
   Indigo accent: --cat-study (#6366F1)
   Dark theme, responsive, A4 print layout
   ================================================================ */

/* ------------------------------------------------------------
   1. Config Panel Layout
   ------------------------------------------------------------ */
.drill-config {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drill-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drill-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------
   2. Grade Tabs
   ------------------------------------------------------------ */
.drill-grade-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.drill-grade-tab {
  padding: 8px 18px;
  border-radius: var(--radius-btn);
  border: 1px solid rgba(99, 102, 241, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  white-space: nowrap;
}

.drill-grade-tab:hover {
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}

.drill-grade-tab.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.55);
  color: var(--cat-study);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.25), 0 0 48px rgba(99, 102, 241, 0.1);
  transform: scale(1.04);
}

/* ------------------------------------------------------------
   3. Operations Checkbox Grid
   ------------------------------------------------------------ */
.drill-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.drill-op-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
  position: relative;
}

.drill-op-checkbox:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.06);
  color: var(--text-primary);
}

.drill-op-checkbox.checked {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--cat-study);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.15);
}

.drill-op-checkbox input[type="checkbox"] {
  display: none;
}

.drill-op-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ------------------------------------------------------------
   4. Slider & Controls Row
   ------------------------------------------------------------ */
.drill-controls-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.drill-count-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.drill-count-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 12px;
}

.drill-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.2);
  outline: none;
  cursor: pointer;
}

.drill-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cat-study);
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.drill-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.6);
}

.drill-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cat-study);
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.4);
}

.drill-count-value {
  font-family: var(--font-hero);
  font-size: 24px;
  font-weight: 700;
  color: var(--cat-study);
  min-width: 36px;
  text-align: center;
}

.drill-count-unit {
  font-size: 14px;
  color: var(--text-secondary);
}

.drill-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.drill-gen-btn {
  padding: 10px 24px;
  font-size: 14px;
}

/* ------------------------------------------------------------
   5. Result Panel
   ------------------------------------------------------------ */
.drill-result-panel {
  min-height: 200px;
  position: relative;
}

.drill-result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
}

.drill-toolbar-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.drill-toolbar-actions {
  display: flex;
  gap: 8px;
}

/* ------------------------------------------------------------
   6. Questions Grid
   ------------------------------------------------------------ */
.drill-questions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.drill-question-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.drill-question-card:hover {
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.04);
}

.drill-q-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drill-q-formula {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.drill-q-answer {
  font-size: 13px;
  color: var(--accent-teal);
  font-weight: 500;
  font-family: var(--font-hero);
  display: none;
}

.drill-q-answer.visible {
  display: block;
}

/* Answer shown state on toolbar */
#btnToggleAnswers.showing {
  color: var(--accent-teal);
  border-color: rgba(19, 221, 196, 0.4);
  background: rgba(19, 221, 196, 0.08);
  box-shadow: 0 0 14px rgba(19, 221, 196, 0.15);
}

/* ------------------------------------------------------------
   7. Print Area (hidden on screen, visible in print)
   ------------------------------------------------------------ */
.drill-print-area {
  display: none;
}

/* ------------------------------------------------------------
   8. Responsive
   ------------------------------------------------------------ */
@media (max-width: 1199px) {
  .drill-questions-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .drill-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .drill-count-wrap {
    min-width: unset;
  }
}

@media (max-width: 768px) {
  .drill-config {
    padding: 18px;
    gap: 16px;
  }
  .drill-questions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .drill-question-card {
    padding: 12px 14px;
  }
  .drill-q-formula {
    font-size: 16px;
  }
  .drill-grade-tabs {
    gap: 6px;
  }
  .drill-grade-tab {
    padding: 7px 14px;
    font-size: 13px;
  }
  .drill-op-checkbox {
    padding: 7px 12px;
    font-size: 13px;
  }
  .drill-controls-row {
    gap: 14px;
  }
  .drill-actions {
    flex-direction: column;
  }
  .drill-gen-btn {
    width: 100%;
    justify-content: center;
  }
  .drill-result-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .drill-config {
    padding: 14px;
    gap: 12px;
  }
  .drill-questions-grid {
    grid-template-columns: 2fr;
    gap: 8px;
  }
  .drill-question-card {
    padding: 10px 12px;
  }
  .drill-q-formula {
    font-size: 15px;
  }
  .drill-grade-tab {
    padding: 6px 12px;
    font-size: 12px;
  }
  .drill-op-checkbox {
    padding: 6px 10px;
    font-size: 12px;
  }
  .drill-count-value {
    font-size: 20px;
  }
  .drill-slider::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }
}

/* ------------------------------------------------------------
   9. Print Styles (A4, 4 columns, answer sheet)
   ------------------------------------------------------------ */
@media print {
  /* Reset */
  *, *::before, *::after {
    color: #000 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-color: #ccc !important;
  }

  /* Hide all UI chrome */
  .navbar,
  .mobile-nav-panel,
  .hamburger-btn,
  .footer,
  .breadcrumb,
  .tool-header,
  .drill-config,
  .drill-result-panel,
  .tool-info-section,
  .related-tools,
  .scroll-top-btn,
  .toast-container {
    display: none !important;
  }

  .page-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-family: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif !important;
    font-size: 14px !important;
  }

  /* Show print area */
  .drill-print-area {
    display: block !important;
    padding: 15mm 12mm;
    width: 100%;
  }

  /* Print header */
  .print-header {
    text-align: center;
    margin-bottom: 8mm;
    padding-bottom: 4mm;
    border-bottom: 1.5px solid #333;
  }

  .print-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6mm;
    letter-spacing: 0.05em;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  }

  .print-info-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 14px;
  }

  .print-info-row span {
    white-space: nowrap;
  }

  /* Print questions grid — 4 columns */
  .print-questions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4mm 6mm;
    margin-bottom: 8mm;
  }

  .print-question-item {
    padding: 3mm 2mm;
    border-bottom: 1px dashed #ddd;
    display: flex;
    align-items: baseline;
    gap: 2mm;
    font-size: 14px;
    min-height: 10mm;
  }

  .print-q-number {
    font-size: 11px;
    color: #888 !important;
    min-width: 6mm;
    text-align: right;
    flex-shrink: 0;
  }

  .print-q-formula {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
  }

  /* Answer sheet */
  .print-answer-sheet {
    padding-top: 6mm;
  }

  .print-answer-title {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 5mm;
    padding-bottom: 3mm;
    border-bottom: 1.5px solid #333;
  }

  .print-answers-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2mm 4mm;
  }

  .print-answer-item {
    font-size: 12px;
    padding: 1.5mm 2mm;
    border-bottom: 1px dotted #ccc;
  }

  .print-answer-item .ans-num {
    color: #888 !important;
    margin-right: 2mm;
  }

  .print-answer-item .ans-val {
    font-weight: 600;
  }

  /* Page break before answer sheet */
  .page-break {
    page-break-before: always;
  }

  /* A4 sizing */
  @page {
    size: A4;
    margin: 10mm;
  }
}
