.es-flashcards {
  --fc-text: #111827;
  --fc-muted: #6b7280;
  --fc-surface: #ffffff;
  --fc-surface-alt: #f9fafb;
  --fc-border: #e5e7eb;
  --fc-accent: #3b82f6;   /* blue */
  --fc-accent-2: #10b981; /* green */
  --fc-accent-3: #f59e0b; /* amber */

  margin: 1.5rem auto 2rem;
  padding: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fc-text);
  max-width: 1440px;
  width: 96%;
}

.es-flashcards-header .subtitle {
  color: var(--fc-muted);
  margin-bottom: 1rem;
}

.es-flashcards-selection-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: end;
}

.es-flashcards-selection-wrapper .js-form-item {
  margin-top: 0;
  margin-bottom: 0;
}

.es-flashcards-selection-wrapper .form-type-radios,
.es-flashcards-selection-wrapper .form-type-checkboxes {
  background: var(--fc-surface-alt);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--fc-border);
}

.es-flashcards-selection-wrapper .form-radios,
.es-flashcards-selection-wrapper .form-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.es-flashcards-selection-wrapper .form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.es-flashcards-selection-wrapper select {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--fc-border);
}

#es-flashcards-selection-form .button_fill {
  width: auto;
  min-width: 200px;
}

.es-flashcards-card {
  perspective: 1000px;
  margin: 1rem 0;
}

.card-inner {
  position: relative;
  width: 100%;
  min-height: 350px;
  height: 50vh;
  max-height: 500px;
  transform-style: preserve-3d;
  transition: transform .5s;
}

.es-flashcards-card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  box-shadow: 0 16px 40px rgba(0,0,0,.12);
  border: 1px solid var(--fc-border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--fc-surface), var(--fc-surface-alt));
  padding: 1rem 1.25rem;
  position: absolute;
  /* Make front and back always the same size by filling the inner container */
  left: 0; right: 0; top: 0; bottom: 0;
  width: 100%;
  height: auto; /* height is controlled by the parent; faces fill it */
  box-sizing: border-box;
  backface-visibility: hidden;
  /* Center the exercise text nicely */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: left;
  overflow-wrap: anywhere;
  overflow-y: auto;
}

.card-content {
  width: 100%;
}

.card-main-word {
  font-weight: bold;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  width: 100%;
  text-align: center;
}

.speak-icon {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  margin-right: 0.25rem;
  color: var(--fc-accent);
  vertical-align: middle;
  transition: transform 0.1s ease;
  font-size: 1.2rem;
}

.speak-icon:hover {
  transform: scale(1.2);
  color: var(--fc-accent-2);
}


/* Front side: bigger, bolder text */
.card-front {
  font-size: 1.2rem;
  line-height: 1.4;
  letter-spacing: .2px;
  /* Stack the three front lines vertically instead of side-by-side */
  flex-direction: column;
  gap: .2rem;
  /* subtle tinted background for the front side */
  background: linear-gradient(180deg, #ffffff, #eef6ff);
}

.card-back {
  transform: rotateY(180deg);
  font-size: 1.2rem;
  line-height: 1.4;
  background: linear-gradient(180deg, #ffffff, #f3f6ff);
  flex-direction: column;
  gap: .35rem;
}

.es-flashcards-controls {
  margin-bottom: 10px;
  position: relative;
  z-index: 100;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.button_fill {
  font-size: 1rem;
  padding: .75rem 1.2rem;
  margin: 0;
  cursor: pointer;
  position: relative;
  z-index: 101;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: box-shadow .2s ease, transform .06s ease, background .2s ease;
  will-change: transform;
}

.es-flashcards-controls .btn-flip {
  background: linear-gradient(180deg, #60a5fa, #3b82f6);
  color: #ffffff;
  border-color: rgba(37, 99, 235, .35);
  flex: 1 1 150px;
  max-width: 250px;
}
.es-flashcards-controls .btn-flip:hover { box-shadow: 0 10px 22px rgba(59, 130, 246, .35); }

.es-flashcards-controls .btn-next,
.es-flashcards-controls .btn-prev {
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  color: #111827;
  border-color: rgba(217, 119, 6, 0.45);
  flex: 1 1 120px;
  max-width: 200px;
}
.es-flashcards-controls .btn-next:hover,
.es-flashcards-controls .btn-prev:hover {
  box-shadow: 0 10px 22px rgba(245, 158, 11, .35);
}

.es-flashcards-controls .btn-iknow {
  background: linear-gradient(180deg, #34d399, #10b981);
  color: #ffffff;
  border-color: rgba(5, 150, 105, .4);
  flex: 1 1 100%;
  max-width: 460px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
}
.es-flashcards-controls .btn-iknow:hover { box-shadow: 0 10px 22px rgba(16, 185, 129, .3); }

.es-flashcards-controls .btn-edit,
.es-flashcards-controls .btn-delete {
  flex: 1 1 120px;
  max-width: 180px;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

.button_fill:active { transform: translateY(1px); }
.button_fill:disabled,
.button_fill[disabled] {
  opacity: .55;
  filter: grayscale(.15);
  cursor: not-allowed;
}

.es-flashcards-add-container {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.es-flashcards-column {
  flex: 1;
  min-width: 300px;
  padding: 1rem;
  background: var(--fc-surface-alt);
  border-radius: 8px;
  border: 1px solid var(--fc-border);
}

.es-column {
  border-left: 4px solid var(--fc-accent);
}

.nl-column {
  border-left: 4px solid var(--fc-accent-3);
}


.es-flashcards-recap {
  text-align: center;
  margin-top: 1rem;
  color: var(--fc-muted);
  font-size: 0.9rem;
}

.admin-controls {
  margin-top: 2rem;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.admin-controls:hover {
  opacity: 1;
}

.es-flashcards-counters {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-weight: bold;
}

.counter-unknown {
  color: var(--fc-accent-3);
}

.counter-known {
  color: var(--fc-accent-2);
}

/* Progress Page Styles */
.es-flashcards-progress-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.es-flashcards-progress-card {
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.es-flashcards-progress-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.progress-section-title {
  margin: 0;
  font-size: 1.25rem;
  color: var(--fc-text);
  border-bottom: 2px solid var(--fc-surface-alt);
  padding-bottom: 0.5rem;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 60px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--fc-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.125rem;
  font-weight: bold;
}

.progress-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
}

.es-progress-bar {
  width: 100%;
  height: 12px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 6px;
  background-color: #ef4444; /* red for unknown part */
  overflow: hidden;
}

/* Chrome/Safari/Edge */
.es-progress-bar::-webkit-progress-bar {
  background-color: #ef4444;
  border-radius: 6px;
}

.es-progress-bar::-webkit-progress-value {
  background-color: #10b981; /* green for known part */
  border-radius: 6px;
  transition: width 0.5s ease-out;
}

/* Firefox */
.es-progress-bar::-moz-progress-bar {
  background-color: #10b981;
  border-radius: 6px;
  transition: width 0.5s ease-out;
}

.progress-percentage {
  font-weight: bold;
  min-width: 45px;
  text-align: right;
  color: var(--fc-accent-2);
}

.es-flashcards-progress-card .actions {
  margin-top: auto;
  padding-top: 0.5rem;
}

.btn-reset-progress {
  width: 100%;
  justify-content: center;
  font-size: 0.875rem;
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border: 1px solid #fecaca !important;
  padding: 0.5rem !important;
}

.btn-reset-progress:hover {
  background: #fecaca !important;
  box-shadow: 0 4px 6px -1px rgba(185, 28, 28, 0.1) !important;
}

.progress-form-actions {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

@media (min-width: 1440px) {
  .es-flashcards-card .card-inner {
    width: 70%;
    min-height: 520px;
  }
}

@media (min-width: 768px) {
  .es-flashcards {
    width: 90%;
  }
  .card-inner {
    max-height: 500px;
  }
}

@media (max-width: 600px) {
  .es-flashcards-selection-wrapper {
    grid-template-columns: 1fr;
  }
  .es-flashcards-selection-wrapper .button_fill {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .es-flashcards-card .card-inner {
    min-height: 300px;
    height: 60vh;
  }
  .es-flashcards-card .card-main-word { font-size: 1.3rem; }
  .es-flashcards-card .card-front { font-size: 1rem; }
  .es-flashcards-card .card-back { font-size: 1rem; }

  .es-flashcards-controls .btn-flip,
  .es-flashcards-controls .btn-next,
  .es-flashcards-controls .btn-prev,
  .es-flashcards-controls .btn-iknow {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
  }

  .es-flashcards-controls .btn-edit,
  .es-flashcards-controls .btn-delete {
    flex: 1 1 48%;
    max-width: none;
    font-size: 0.8rem;
    padding: 0.4rem;
  }
}
