/**
 * Listening-IELTS Authentic Flowchart Completion Stylesheet
 * Computer-Delivered IELTS Flowchart Experience with Drag & Drop / Click-to-Place
 */

.listening-flowchart-container {
  margin-top: 1.25rem;
  margin-bottom: 2rem;
  font-family: inherit;
}

/* 1. Flowchart Option Bank */
.flowchart-bank-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

html.dark .flowchart-bank-card,
[data-theme="dark"] .flowchart-bank-card {
  background: #0f172a;
  border-color: #334155;
}

.flowchart-bank-title {
  font-size: 0.825rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #047857;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

html.dark .flowchart-bank-title,
[data-theme="dark"] .flowchart-bank-title {
  color: #34d399;
  border-color: #334155;
}

.flowchart-tokens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.625rem;
}

/* Individual Token Chip */
.flowchart-token-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  cursor: grab;
  user-select: none;
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.flowchart-token-chip:hover {
  border-color: #10b981;
  background-color: #f0fdf4;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.1);
}

.flowchart-token-chip:active {
  cursor: grabbing;
}

html.dark .flowchart-token-chip,
[data-theme="dark"] .flowchart-token-chip {
  background: #1e293b;
  border-color: #475569;
  color: #f1f5f9;
}

html.dark .flowchart-token-chip:hover,
[data-theme="dark"] .flowchart-token-chip:hover {
  background: #064e3b;
  border-color: #34d399;
}

.flowchart-token-chip .token-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #047857;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
  border: 1px solid #a7f3d0;
}

html.dark .flowchart-token-chip .token-letter,
[data-theme="dark"] .flowchart-token-chip .token-letter {
  background: #065f46;
  color: #a7f3d0;
  border-color: #047857;
}

/* Active / Selected Token in Bank */
.flowchart-token-chip.is-selected {
  border-color: #059669 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3) !important;
  transform: scale(1.03);
}

/* Used Token State */
.flowchart-token-chip.is-used {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
  border-style: dashed;
}

/* 2. Flowchart Steps */
.flowchart-steps-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.flowchart-step-card {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.flowchart-step-card:hover {
  border-color: #cbd5e1;
}

html.dark .flowchart-step-card,
[data-theme="dark"] .flowchart-step-card {
  background: #0f172a;
  border-color: #334155;
}

.flowchart-step-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: #047857;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

html.dark .flowchart-step-header,
[data-theme="dark"] .flowchart-step-header {
  color: #34d399;
}

.flowchart-step-text {
  font-size: 0.9375rem;
  color: #1e293b;
  line-height: 1.7;
}

html.dark .flowchart-step-text,
[data-theme="dark"] .flowchart-step-text {
  color: #e2e8f0;
}

/* Flowchart Arrow Connector */
.flowchart-connector {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 1.75rem;
  color: #10b981;
}

.flowchart-connector svg {
  width: 1.25rem;
  height: 1.25rem;
  animation: flowBounce 2s infinite ease-in-out;
}

@keyframes flowBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* 3. Interactive Dropzone Gaps */
.flowchart-dropzone {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 140px;
  min-height: 38px;
  padding: 0.25rem 0.625rem;
  margin: 0 0.25rem;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 0.625rem;
  vertical-align: middle;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.flowchart-dropzone:hover {
  border-color: #10b981;
  background: #f0fdf4;
}

html.dark .flowchart-dropzone,
[data-theme="dark"] .flowchart-dropzone {
  background: #1e293b;
  border-color: #475569;
}

.flowchart-dropzone .q-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

html.dark .flowchart-dropzone .q-badge,
[data-theme="dark"] .flowchart-dropzone .q-badge {
  background: #065f46;
  color: #a7f3d0;
  border-color: #047857;
}

.flowchart-dropzone .dropzone-placeholder {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #94a3b8;
  font-style: italic;
}

/* When a bank token is selected, dropzones glow with an invitation */
.flowchart-dropzone.can-drop {
  border-color: #10b981 !important;
  background: #f0fdf4 !important;
  border-style: solid !important;
  animation: dropPulse 1.5s infinite;
}

@keyframes dropPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.15); }
}

/* Filled Dropzone State */
.flowchart-dropzone.has-token {
  background: #ffffff;
  border: 1.5px solid #10b981;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.1);
}

html.dark .flowchart-dropzone.has-token,
[data-theme="dark"] .flowchart-dropzone.has-token {
  background: #064e3b;
  border-color: #34d399;
}

.flowchart-dropzone .placed-token-text {
  font-size: 0.875rem;
  font-weight: 700;
  color: #065f46;
}

html.dark .flowchart-dropzone .placed-token-text,
[data-theme="dark"] .flowchart-dropzone .placed-token-text {
  color: #a7f3d0;
}

.flowchart-dropzone .unslot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
  margin-left: auto;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.flowchart-dropzone .unslot-btn:hover {
  background: #ef4444;
  color: #ffffff;
  transform: scale(1.1);
}

/* 4. Review & Grading States */
.flowchart-dropzone.is-correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
}

.flowchart-dropzone.is-incorrect {
  border-color: #f43f5e !important;
  background: #fff1f2 !important;
}

.flowchart-dropzone.is-incorrect .placed-token-text {
  text-decoration: line-through;
  color: #be123c !important;
}

.flowchart-correct-key-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #ecfdf5;
  border: 1px solid #10b981;
  border-radius: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: #065f46;
  margin-left: 0.35rem;
}

@media (max-width: 640px) {
  .flowchart-tokens-grid {
    grid-template-columns: 1fr;
  }
  .flowchart-dropzone {
    width: 100%;
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
  }
}

/* 5. Master Title & Gap-Fill Flowcharts */
.flowchart-master-title {
  background: linear-gradient(to right, rgba(16, 185, 129, 0.08), rgba(241, 245, 249, 0.5));
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 0.875rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

html.dark .flowchart-master-title,
[data-theme="dark"] .flowchart-master-title {
  background: linear-gradient(to right, rgba(16, 185, 129, 0.15), rgba(15, 23, 42, 0.6));
  border-color: rgba(52, 211, 153, 0.25);
}

.flowchart-step-card.gap-fill-step {
  padding: 1.15rem 1.35rem;
}

.flowchart-step-card.gap-fill-step .flowchart-step-header {
  font-size: 0.95rem;
  color: #065f46;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

html.dark .flowchart-step-card.gap-fill-step .flowchart-step-header,
[data-theme="dark"] .flowchart-step-card.gap-fill-step .flowchart-step-header {
  color: #6ee7b7;
  border-bottom-color: #334155;
}

.flowchart-step-card.gap-fill-step input.fill-in-blank {
  margin: 0 0.25rem;
}
