/* ====================================================== */
/*                  1. ROOT & GLOBAL STYLES               */
/* ====================================================== */
:root {
  --primary-color: hsl(215, 50%, 47%);
  --primary-hover: hsl(215, 41%, 36%);
  --primary-light: hsl(215, 50%, 95%);
  --text-dark: #1f2937;
  --text-light: #4b5563;
  --bg-main: #f8fafc;
  --bg-panel: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: var(--primary-color);
  --success-color: #16a34a;
  --error-color: #dc2626;
  --answered-color: hsl(170, 45%, 45%);

  --body-font: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --panel-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--body-font);
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 2;
}

#app {
  transition: font-size 0.2s ease-in-out;
}

.hidden {
  display: none !important;
}

h1, h2, h3 {
  color: var(--text-dark);
}

h1 { margin-bottom: 1rem; font-weight: 700; }
h2 { margin-bottom: 1.5rem; font-weight: 600; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
h3 { margin-bottom: 1rem; font-weight: 500; }

/* ====================================================== */
/*                2. FONT SIZE UTILITIES                  */
/* ====================================================== */
.font-size-small   { font-size: 0.875rem; }
.font-size-medium  { font-size: 1rem; }
.font-size-large   { font-size: 1.125rem; }
.font-size-xlarge  { font-size: 1.25rem; }

/* ====================================================== */
/*              3. TOP CONTROL BAR (HEADER)               */
/* ====================================================== */
#topControlBar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background-color: var(--bg-panel);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid var(--border-color);
  gap: 1.5rem;
}

.top-bar-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-bar-section.top-bar-nav {
  flex-grow: 1;
  justify-content: center;
}

.top-bar-btn {
  background-color: transparent;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-family: var(--body-font);
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
  color: var(--text-light);
}
.top-bar-btn:hover { background-color: var(--bg-main); color: var(--primary-color); }
.top-bar-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#menuButton { border-color: var(--border-color); }

.menu-dropdown { position: relative; display: inline-block; }
.dropdown-content { position: absolute; top: 100%; left: 0; background-color: var(--bg-panel); min-width: 180px; box-shadow: var(--panel-shadow); border-radius: var(--border-radius); z-index: 101; border: 1px solid var(--border-color); padding: 0.5rem 0; margin-top: 0.25rem; }
.dropdown-content a { color: var(--text-dark); padding: 0.75rem 1rem; text-decoration: none; display: block; cursor: pointer; font-size: 0.9rem; transition: background-color 0.2s, color 0.2s; }
.dropdown-content a:hover { background-color: var(--primary-light); color: var(--primary-color); }

.timer-display { font-weight: 600; background-color: var(--bg-main); padding: 0.5rem 0.75rem; border-radius: var(--border-radius); font-variant-numeric: tabular-nums; color: var(--text-dark); }

/* --- Question Nav Grid --- */
#questionNavGrid {
  display: flex;
  align-items: normal;
  overflow-x: auto;
  white-space: nowrap;
  gap: 6px;
  padding: 6px 4px;
  max-width: 37vw;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) #e0e0e0;
}
#questionNavGrid::-webkit-scrollbar { height: 6px; }
#questionNavGrid::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
#questionNavGrid::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 10px; }
#questionNavGrid::-webkit-scrollbar-thumb:hover { background: var(--primary-hover); }

.q-nav-item { width: 32px; height: 32px; flex-shrink: 0; border: 1px solid #94a3b8; border-radius: 4px; background-color: var(--bg-panel); color: var(--text-light); cursor: pointer; font-weight: 500; transition: all 0.2s; padding: 0; }
.q-nav-item:hover { border-color: var(--primary-color); background-color: var(--primary-light); }
.q-nav-item.answered { background-color: var(--answered-color); color: white; border-color: var(--answered-color); }
.q-nav-item.current { background-color: var(--primary-color); color: white; border-color: var(--primary-color); transform: scale(1.1); font-weight: 700; box-shadow: 0 0 8px rgba(0,0,0,0.2); }

/* --- Passage/Section Tabs --- */
.passage-tabs { border: 1px solid var(--border-color); border-radius: var(--border-radius); overflow: hidden; padding: 0; }
.passage-tab { border: none; background-color: transparent; padding: 0.5rem 1rem; cursor: pointer; transition: all 0.2s ease; border-right: 1px solid var(--border-color); color: var(--text-light); }
.passage-tab:last-child { border-right: none; }
.passage-tab:hover { background-color: var(--primary-light); }
.passage-tab.active { background-color: var(--primary-color); color: white; font-weight: 600; }

/* ====================================================== */
/*               4. WELCOME, HOME & SETUP VIEWS           */
/* ====================================================== */
.welcome-view { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.welcome-box { background-color: var(--bg-panel); padding: 2rem 3rem; border-radius: 12px; box-shadow: var(--panel-shadow); max-width: 500px; text-align: center; }
#nameInput { display: block; width: 100%; padding: 0.75rem; margin: 1.5rem 0; border: 1px solid var(--border-color); border-radius: var(--border-radius); font-size: 1rem; }
#nameInput:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px hsla(215, 50%, 47%, 0.3); }
.error-message { color: var(--error-color); margin-top: 0.5rem; }

/* --- Home Menu --- */
#home { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding: 2rem; text-align: center; }
.home-menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; width: 100%; max-width: 800px; margin: 2rem auto 0; }
.home-menu-grid button { height: 100%; width: 100%; padding: 1rem; background-color: var(--bg-panel); color: var(--text-dark); border: 1px solid var(--border-color); box-shadow: var(--panel-shadow); font-size: 1.5rem; font-weight: 600; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0.75rem; }
.home-menu-grid button:not(.review-button) { aspect-ratio: 1 / 1; }
.home-menu-grid .review-button { grid-column: 1 / -1; background-color: var(--primary-color); border-color: var(--primary-color); color: white; }
.home-menu-grid button:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05); border-color: var(--primary-color); }
.home-menu-grid .review-button:hover { background-color: var(--primary-hover); border-color: var(--primary-hover); }
.home-menu-grid button svg { width: 48px; height: 48px; }

/* --- Practice Setup Views (All Skills) --- */
.setup-container { background-color: var(--bg-panel); padding: 2rem 3rem; border-radius: 12px; box-shadow: var(--panel-shadow); max-width: 900px; margin: 3rem auto; }
.mode-buttons-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin: 2rem 0; }
.mode-select-btn { background-color: var(--bg-panel); color: var(--text-dark); border: 1px solid var(--border-color); box-shadow: var(--panel-shadow); padding: 1.25rem 1rem; font-size: 1.05rem; font-weight: 600; text-align: center; transition: all 0.2s; min-height: 80px; }
.mode-select-btn:hover { transform: translateY(-4px); box-shadow: 0 8px 12px -3px rgba(0,0,0,0.07); border-color: var(--primary-color); background-color: var(--primary-color); color: white; }
.mode-select-btn.active { border-color: var(--primary-color); color: var(--primary-color); box-shadow: 0 0 0 3px hsla(215, 50%, 47%, 0.3); transform: translateY(-2px); }
.mode-select-btn.active:hover {
    background-color: var(--primary-hover); /* A slightly darker blue for feedback */
    color: white; /* Ensure text is white */
    border-color: var(--primary-hover);
}
/* --- Dynamic Content Area in Setup Views --- */
.practice-content-area { margin-top: 20px; padding: 20px; background-color: var(--bg-main); border: 1px solid var(--border-color); border-radius: 8px; min-height: 100px; }
.practice-content-area > * { animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.test-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}.test-select-btn { text-align: left; background-color: var(--bg-panel); color: var(--text-dark); border: 1px solid var(--border-color); font-weight: 500; padding: 0.75rem 1.25rem; transition: all 0.2s ease; }
.test-select-btn:hover { border-color: var(--primary-color); background-color: var(--primary-light); color: var(--primary-color); transform: translateX(4px); box-shadow: var(--panel-shadow); }
.passage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.passage-grid button { background-color: var(--bg-panel); color: var(--text-dark); border: 1px solid var(--border-color); box-shadow: var(--panel-shadow); padding: 1.25rem 1rem; font-size: 1.05rem; font-weight: 600; text-align: center; transition: all 0.2s; min-height: 80px; }
.passage-grid > button:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px -3px rgba(0,0,0,0.07);
    border-color: var(--primary-color);
    background-color: var(--primary-color); /* ADD THIS LINE */
    color: white;                           /* CHANGE THIS LINE */
}
.passage-columns-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; text-align: left; }
.passage-column { background-color: var(--bg-main); padding: 1rem; border-radius: var(--border-radius); }
.passage-column h4 { margin-top: 0; margin-bottom: 1rem; text-align: center; color: var(--text-light); }
.passage-column-btn { display: block; width: 100%; text-align: left; margin-bottom: 0.5rem; background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-light); font-size: 0.9rem; padding: 0.5rem 0.75rem; font-weight: 500; }
.passage-column-btn:hover { color: var(--primary-color); border-color: var(--primary-color); background-color: var(--primary-light); }

/* ====================================================== */
/*               5. GENERAL BUTTONS & INPUTS              */
/* ====================================================== */
button { font-family: var(--body-font); font-size: 1rem; padding: 0.75rem 1.5rem; border-radius: var(--border-radius); border: 1px solid var(--primary-color); background-color: var(--primary-color); color: white; cursor: pointer; transition: all 0.2s ease; font-weight: 600; }
button:hover { background-color: var(--primary-hover); border-color: var(--primary-hover); box-shadow: var(--panel-shadow); }
button:disabled { background-color: var(--text-light); border-color: var(--text-light); cursor: not-allowed; opacity: 0.8; }

button.back-button { display: block; width: fit-content; background-color: transparent; color: var(--text-light); border-color: var(--border-color); margin-bottom: 1.5rem; padding: 0.5rem 1rem; font-weight: 500; }
button.back-button:hover { background-color: var(--bg-main); color: var(--text-dark); }

/* ====================================================== */
/*        6. READING & LISTENING TEST VIEW STYLES         */
/* ====================================================== */
.test-view { display: flex; height: calc(100vh - 67px); }
.left-panel, .right-panel { flex: 1 1 50%; overflow-y: auto; padding: 1.5rem 2rem; position: relative; }
.left-panel { background-color: var(--bg-main); border-right: 1px solid var(--border-color); }
.right-panel { background-color: var(--bg-panel); }
.resizer { flex: 0 0 10px; background-color: #e5e7eb; cursor: col-resize; display: flex; align-items: center; justify-content: center; color: #9ca3af; }
.resizer:hover { background-color: var(--primary-color); color: white; }
.passage-panel { padding: 0.5rem; }

.test-view-single { max-width: 1200px; margin: 2rem auto; padding: 1.5rem 2rem; background-color: var(--bg-panel); border-radius: var(--border-radius); box-shadow: var(--panel-shadow); display: flex; flex-direction: column; }
.bottom-controls { padding: 1.5rem 0 0 0; margin-top: 1rem; border-top: 1px solid var(--border-color); background-color: var(--bg-panel); }
#results { margin-top: 1.5rem; padding: 1rem; background-color: var(--primary-light); border-radius: var(--border-radius); border: 1px solid var(--border-color); }

/* ====================================================== */
/*                 7. WRITING TEST VIEW                   */
/* ====================================================== */
.test-view-writing { display: grid; grid-template-columns: 40% 60%; height: calc(100vh - 67px); gap: 1rem; padding: 1rem; }
.writing-prompts, .writing-inputs { background-color: var(--bg-panel); border-radius: var(--border-radius); box-shadow: var(--panel-shadow); overflow-y: auto; display: flex; flex-direction: column; }
.writing-prompt-panel { padding: 1.5rem; }
.writing-tabs { display: flex; border-bottom: 1px solid var(--border-color); }
.writing-tab { flex-grow: 1; padding: 0.75rem; border: none; background-color: var(--bg-main); color: var(--text-light); border-bottom: 3px solid transparent; font-weight: 500; cursor: pointer; }
.writing-tab.active { background-color: var(--bg-panel); color: var(--primary-color); font-weight: 600; border-bottom-color: var(--primary-color); }
.writing-input-panel { padding: 1rem; display: flex; flex-direction: column; flex-grow: 1; }
.writing-textarea { width: 100%; flex-grow: 1; border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: 1rem; font-family: var(--body-font); font-size: inherit; line-height: 1.6; resize: none; }
.writing-textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px hsla(215, 50%, 47%, 0.3); }
.writing-meta { padding-top: 0.5rem; text-align: right; color: var(--text-light); font-size: 0.9rem; }
.prompt-box { border: 1px solid var(--border-color); padding: 1rem 1.5rem; margin: 1.5rem 0; background-color: var(--bg-main); border-radius: var(--border-radius); }
.writing-prompt-panel img { cursor: zoom-in; transition: transform 0.2s; }
.writing-prompt-panel img:hover { transform: scale(1.02); }

/* ====================================================== */
/*                  8. QUESTION STYLES                    */
/* ====================================================== */

.question-block {
  margin-bottom: 2rem;
  padding: 0;
  border: none;
  background-color: transparent;
}

.question-block .instructions {
  background-color: var(--primary-light);
  color: var(--text-dark);
  padding: 1rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
}

.instructions p:last-child {
  margin-bottom: 0;
}

.instructions strong {
  font-weight: 600;
}

/* This is the container for the list of options in matching questions */
.options-box {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
.options-box ul {
  list-style-type: none;
  padding-left: 0;
  margin-bottom: 0;
}
.options-box li {
  padding: 0.25rem 0;
}

.question-number-marker {
  border-radius: 4px;
  padding: 2px;
  margin: -2px; 
  transition: background-color 0.2s;
  color: var(--primary-color);
  font-weight: 700;
}
.question-number-marker.focused {
  background-color: hsla(215, 50%, 47%, 0.2);
  outline: 2px solid var(--primary-color);
}


.answer-container {
  display: inline-block;
  vertical-align: middle;
  margin: 0 0.25em; /* A little space around the component */
}

.radio-options,
.checkbox-options {
  display: block; /* Take up their own line */
  margin-top: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  background-color: #fcfdff;
}
.checkbox-options[disabled] {
    background-color: var(--bg-main);
    opacity: 0.7;
}

.radio-options label,
.checkbox-options label {
  display: block;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.radio-options label:hover,
.checkbox-options label:hover {
  background-color: hsl(220, 25%, 95%);
}
.radio-options input[type="radio"],
.checkbox-options input[type="checkbox"] {
  margin-right: 0.75rem;
  accent-color: var(--primary-color);
  transform: scale(1.1);
  cursor: pointer;
}
.checkbox-options input:disabled {
    cursor: not-allowed;
}

.answer-container input[type="text"], 
.answer-container select {
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-panel);
  font-family: var(--body-font);
  font-size: 1em;
  padding: 3px 10px;
  transition: all 0.2s ease;
  max-width: 150px;
}
.answer-container input[type="text"]:focus, 
.answer-container select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px hsla(215, 50%, 47%, 0.3);
}

select[name^="q"] { 
    font-weight: 500;
}

select:invalid {
  color: var(--text-light);
  font-style: italic;
}


.question-block table {
  width: 100%;
  border-collapse: collapse; /* Crucial for modern table styling */
  margin: 1.5rem 0; /* Adds space above and below the table */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius); /* Rounded corners for the table */
  overflow: hidden; /* Ensures content respects the rounded corners */
  font-size: 0.95em; /* Slightly smaller font for better fit */
}

/* --- Table Header Cells (th) --- */
.question-block th {
  background-color: var(--bg-main); /* A very light grey background */
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase; /* Optional: makes headers stand out */
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

/* --- All Table Cells (th and td) --- */
.question-block th,
.question-block td {
  padding: 0.75rem 1rem; /* THIS IS THE KEY FIX: Adds internal padding */
  text-align: left;
  border-bottom: 1px solid var(--border-color); /* Horizontal lines between rows */
}

/* --- Table Body Rows (for hover effect) --- */
.question-block tbody tr:hover {
  background-color: var(--primary-light); /* Highlights the row on hover */
}

/* --- Remove the bottom border from the very last row --- */
.question-block tbody tr:last-child td {
  border-bottom: none;
}

/* Fix for the first table in test2.json which has nested content */
.question-block td ul,
.question-block td p {
    margin-bottom: 0;
}
.question-block td em {
    color: var(--text-light);
    font-style: italic;
    display: block;
    font-size: 0.9em;
    line-height: 1.2;
}

/* Add this new rule to style.css */

/* --- Specific rule for large images like maps --- */
.test-map {
  max-width: 700px;  /* A much larger, more readable maximum size */
  width: 100%;       /* Ensures the map is responsive and fills its container */
  display: block;
  margin: 1.5rem auto; /* Centers the map horizontally */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: white; /* Ensures it looks good if it has transparency */
}
/* ====================================================== */
/*                  9. REVIEW & RESULTS                   */
/* ====================================================== */
.review-item { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin-bottom: 1rem; background-color: var(--bg-main); text-align: left; }
.review-item-info { flex-grow: 1; }
.review-item-info h4 { margin: 0 0 0.25rem 0; color: var(--primary-color); }
.review-item-info p { margin: 0; font-size: 0.9rem; color: var(--text-light); }
.review-item button { padding: 0.5rem 1rem; font-size: 0.9rem; }

.comparison-tables-wrapper { display: flex; gap: 1.5rem; margin-top: 1.5rem; flex-wrap: wrap; }
.comparison-table { flex: 1; min-width: 300px; border: 1px solid var(--border-color); border-radius: var(--border-radius); background-color: var(--bg-panel); overflow: hidden; display: flex; flex-direction: column; }
.comparison-table h4 { background-color: var(--primary-light); color: var(--text-dark); font-weight: 600; padding: 0.75rem 1rem; margin: 0; border-bottom: 1px solid var(--border-color); }
.comparison-table table { width: 100%; border-collapse: collapse; }
.comparison-table th, .comparison-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); font-size: 0.95rem; }
.comparison-table tbody tr:last-child td { border-bottom: none; }
.comparison-table th { font-weight: 600; background-color: var(--bg-main); color: var(--text-light); }
.comparison-table td:first-child { font-weight: 600; width: 60px; text-align: center; color: var(--text-light); border-right: 1px solid var(--border-color); }
.correct-cell { color: var(--success-color); font-weight: 700; }
.incorrect-cell { color: var(--error-color); font-weight: 700; }

.results-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 20px;
    flex-wrap: wrap; /* Allows buttons to stack on small screens */
}

.finish-btn {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.finish-btn:hover {
    background-color: #15803d; /* A darker green */
    border-color: #15803d;
}
/* ====================================================== */
/*                 10. LIGHTBOX & MODALS                  */
/* ====================================================== */
.lightbox-overlay { position: fixed; z-index: 1000; padding: 50px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.85); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox-content { margin: auto; display: block; max-width: 90%; max-height: 90%; animation: zoom 0.4s; }
@keyframes zoom { from {transform:scale(0)} to {transform:scale(1)} }
.lightbox-close { position: absolute; top: 15px; right: 35px; color: #f1f1f1; font-size: 40px; font-weight: bold; transition: 0.3s; cursor: pointer; }
.lightbox-close:hover, .lightbox-close:focus { color: #bbb; text-decoration: none; }

/* ====================================================== */
/*               11. RESPONSIVE ADJUSTMENTS               */
/* ====================================================== */
@media (max-width: 768px) {
  .home-menu-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    gap: 1rem;
  }
  .home-menu-grid .review-button {
    grid-column: auto;
  }
  .home-menu-grid button:not(.review-button) {
    aspect-ratio: auto;
    min-height: 120px;
  }
  .test-view, .test-view-writing {
    flex-direction: column;
    height: auto;
    display: flex; /* Override grid for writing view on small screens */
  }
  .left-panel, .right-panel, .writing-prompts, .writing-inputs {
    flex-basis: auto;
    height: 50vh;
  }
  .resizer {
    height: 10px;
    width: 100%;
    cursor: row-resize;
  }
}
.question-sentence {
  display: inline;
}

.single-question:not(:last-child) .question-sentence::after {
    content: " ";
}

.highlighted-text {
  background-color: #fffb8f; /* A pleasant, IELTS-like yellow */
  border-radius: 2px;
}

/* Style for the custom right-click menu */
.highlighter-menu {
  position: absolute;
  z-index: 1000;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--panel-shadow);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.highlighter-menu button {
  width: 100%;
  background-color: transparent;
  color: var(--text-dark);
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  text-align: left;
  font-weight: 500;
}

.highlighter-menu button:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

/* ====================================================== */
/*      12. REVISED GLOBAL ELEMENT STYLES                 */
/* ====================================================== */

ul, ol {
  padding-left: 20px; /* A standard indent for lists */
  margin-bottom: 1rem;
}
ul { list-style-type: disc; } 
ol { list-style-type: decimal; }

b, strong {
  padding-right: 0.5rem;
  margin: 0;
  
  font-weight: 700;
}

.question-block img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto; /* Center the image with some vertical space */
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

/* REPLACE the old .diagram-label rules with these */

.diagram-label {
  position: absolute; /* This lets us use top/left coordinates */
  max-width: 50%;     /* Prevent text blocks from becoming too wide */
  background-color: transparent; /* Make it look like plain text */
  padding: 0;
  border: none;
  box-shadow: none;
  /* We REMOVE the transform so the top-left corner aligns to the coordinates */
}

/* Style the question number inside the label text */
.diagram-label .question-number-marker {
  font-weight: 700;
  color: var(--primary-color);
  padding: 0;
  margin: 0;
}

/* Keep the input field styling */
.diagram-label input[type="text"] {
  border: 1px solid var(--border-color);
  padding: 4px;
  width: 120px;
  border-radius: 4px;
}
/* Add these styles at the end of Section 8 for Interactive Diagrams */

.diagram-container {
  position: relative; /* This is the anchor for the labels */
  max-width: 800px;   /* Or whatever max-width fits your design */
  margin: 1.5rem auto;
}

.diagram-container img {
  display: block;     /* Ensures it behaves predictably */
  width: 100%;        /* Makes the image responsive */
  height: auto;
}
/* Add this to your style.css file */

.play-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  margin: 1rem 0;
  transition: background-color 0.2s;
}

.play-audio-btn:hover:not(:disabled) {
  background-color: var(--primary-dark);
}

.play-audio-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  color: #666666;
}

.play-audio-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Add this to your style.css file */

.timer-display.final-warning {
  color: var(--error-color);
  font-weight: 700;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ====================================================== */
/*          13. CUSTOM CONTENT STYLES (Notes)             */
/* ====================================================== */

.notes-layout {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--bg-panel);
}

.notes-layout > h4 {
  padding: 1rem 1.5rem;
  margin: 0;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
}

.notes-section {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}
.notes-section:last-child {
  border-bottom: none;
}

.notes-left-col {
  flex: 0 0 30%; /* Left column takes up 30% of the width */
  padding: 1.5rem;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-main);
}

.notes-left-col h4 {
  margin: 0;
  color: var(--primary-color);
}

.notes-right-col {
  flex: 1; /* Right column takes the remaining space */
  padding: 1.5rem;
}

.notes-right-col p {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.notes-right-col ul {
  margin-top: 0;
  margin-bottom: 1.5rem;
}
.notes-right-col ul:last-child {
    margin-bottom: 0;
}
/* ====================================================== */
/*          15. REVIEW TABS STYLES (NEW)                  */
/* ====================================================== */

.review-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.review-tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border: none;
  background-color: transparent;
  color: var(--text-light);
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 3px solid transparent;
  transform: translateY(2px); /* Aligns the bottom border with the container's border */
  transition: all 0.2s ease-in-out;
}

.review-tab:hover {
  color: var(--primary-color);
  background-color: var(--primary-light);
}

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

/* ====================================================== */
/*         16. WRITING REVIEW STYLES (NEW)                */
/* ====================================================== */

.writing-review-section {
  margin-bottom: 2.5rem;
}

.writing-review-section h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 0.5rem;
}

.prompt-box-review {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem 1.5rem;
  line-height: 1.6;
}

.answer-box-review {
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  line-height: 1.8;
  white-space: pre-wrap; /* This is crucial: it preserves line breaks and wraps long lines */
  font-family: var(--body-font);
  font-size: 1rem;
  color: var(--text-dark);
}

.review-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
} 

/* ====================================================== */
/*               HOME VIEW SUB-MESSAGE                    */
/* ====================================================== */
.home-sub-message {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    font-style: italic;
}

/* ====================================================== */
/*                SPEAKING TEST VIEW                      */
/* ====================================================== */
.speaking-prompt-container {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    max-width: 700px;
    margin: 2rem auto;
    text-align: center;
}

.speaking-prompt-container h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.speaking-question {
    font-size: 1.5rem; /* Larger font for the question */
    line-height: 1.4;
    color: var(--text-dark);
}

#speakingControls {
    text-align: center;
    margin-top: 1rem;
}

.speaking-timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.speaking-timer h3 {
    margin: 0;
    color: var(--text-dark);
}

.speaking-timer .timer-display {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    background-color: var(--bg-light);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-width: 150px;
    text-align: center;
}

.speaking-timer p {
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Cue Card Styling */
.cue-card, .cue-card-review {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1.5rem;
    text-align: left;
    margin-top: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.cue-card-main {
    font-weight: 600;
    margin-bottom: 1rem;
}

.cue-card ul {
    list-style-type: disc;
    padding-left: 20px;
    margin: 0;
    color: var(--text-dark);
}

.cue-card ul li {
    margin-bottom: 0.5rem;
}

/* Review View for Speaking */
#reviewSpeakingContent {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
#reviewSpeakingContent h3 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}
#reviewSpeakingContent h3:first-child {
    margin-top: 0;
}
#reviewSpeakingContent ul {
    list-style-position: inside;
    padding-left: 0;
}
#reviewSpeakingContent ul li {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
/* ====================================================== */
/*             SPEAKING PROGRESS INDICATOR                */
/* ====================================================== */
#speakingProgressIndicator {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 700px;
    margin: 1.5rem auto 0;
    padding: 0 1rem;
}

#speakingProgressIndicator h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

.progress-step {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-light);
    background-color: var(--bg-light);
    transition: all 0.3s ease;
}
.progress-step.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 700;
    background-color: #fff;
}
.progress-step.completed {
    border-color: var(--success-color);
    background-color: var(--success-color);
    color: #fff;
}
.progress-line {
    flex-grow: 1;
    height: 2px;
    background-color: var(--border-color);
    margin: 0 10px;
}
.progress-line.completed {
    background-color: var(--success-color);
}

/* ====================================================== */
/*          SPEAKING PRACTICE & REVIEW CONTROLS           */
/* ====================================================== */
.examiner-status, .user-status {
    font-style: italic;
    color: var(--text-light);
    padding: 1rem;
}
.practice-controls {
    margin-top: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-light);
}
.practice-controls p {
    margin: 0 0 1rem;
    font-weight: 500;
}
.practice-controls audio {
    width: 100%;
}
.practice-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
.retry-btn {
    background-color: transparent;
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.retry-btn:hover {
    background-color: var(--warning-color);
    color: #fff;
}

.review-recordings h3 {
    margin-top: 2rem;
    color: var(--primary-color);
}
.practice-recording-review {
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}
.practice-recording-review p {
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.practice-recording-review audio {
    width: 100%;
}

/* ====================================================== */
/*                 MODEL ANSWER LIGHTBOX                  */
/* ====================================================== */
#lightboxCaption {
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
}
.dialogue-text p {
    margin-bottom: 1rem;
    line-height: 1.6;
}
.dialogue-text b {
    color: var(--primary-color);
}
/* --- Styles for Matching Question Layout Tables --- */
.matching-question-table {
  width: relative; /* Allows the table to shrink to fit content */
  border-collapse: collapse;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.matching-question-table td {
  padding: 0.4rem 1rem;
  border-bottom: none;
  vertical-align: middle; /* Aligns text and dropdown nicely */
}

/* Style the right column to be narrower and centered */
.matching-question-table td:first-child {
  width: 400px;
  text-align: left;
}

/* Remove the bottom border from the last row */
.matching-question-table tr:last-child td {
  border-bottom: none;
}

.matching-question-table tr:hover {
  background-color: var(--primary-light);
}

/* AI Feedback & Loader Styles */
.loader {
    border: 5px solid #f3f3f3; /* Light grey */
    border-top: 5px solid var(--primary-color); /* Blue */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1.5s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-feedback-box {
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
    text-align: left;
    white-space: pre-wrap; /* Preserves line breaks and spacing from AI */
    line-height: 1.6;
    font-family: inherit; /* Ensures it uses the site's font */
}

/* Style the headings and lists that the AI will generate */
.ai-feedback-box h3 {
    color: var(--primary-color);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 1.2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

.ai-feedback-box ul {
    list-style-type: disc;
    list-style-position: inside;
    padding-left: 1rem;
    margin-bottom: 1rem;
}

.ai-feedback-box li {
    margin-bottom: 0.5rem;
}
.writing-prompts {
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none;     /* IE 10+ */
    user-select: none;         /* Standard syntax */
}