* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  margin: 0;
  padding: 0;
}

.container {
  max-width: 600px;
  margin: 50px auto;
  text-align: center;
}

h1 {
  color: white;
  margin-bottom: 5px;
}

.subtitle {
  color: #e0f7ff;
  margin-bottom: 25px;
}

.form-card {
  background: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.input-group {
  text-align: left;
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  font-size: 14px;
  margin-bottom: 5px;
  color: #333;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  outline: none;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  border-color: #4facfe;
}

textarea {
  resize: none;
  height: 80px;
}

.row {
  display: flex;
  gap: 10px;
}

.section-box {
  margin-top: 20px;
  text-align: left;
}

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

.section h4 {
  margin: 0 0 8px 0;
  color: #333;
}

.section input,
.section select {
  margin-top: 6px;
}

.toggle-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.loading {
  display: none;
  margin-top: 10px;
  color: #4facfe;
  font-weight: bold;
}

.btn {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  background: #4facfe;
  border: none;
  color: white;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover {
  background: #00c6ff;
  transform: scale(1.02);
}

.result {
  margin-top: 15px;
}

#downloadLink {
  font-weight: bold;
  color: #4facfe;
  text-decoration: none;
}

#downloadLink:hover {
  text-decoration: underline;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 40px;
  background: white;
  border-bottom: 1px solid #ddd;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 24px;
  font-weight: bold;
}

.nav-links {
  display: flex;
  gap: 30px;
}

.nav-links a {
  text-decoration: none;
  color: #333;
  font-weight: 500;
}

.auth-buttons {
  display: flex;
  gap: 12px;
}

.auth-buttons button {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

.profile-btn {
    cursor: pointer;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    color: #111;
    padding: 8px 12px;
    border-radius: 8px;
}

.profile-btn:hover {
    background: #f1f5f9;
}

.nav-links a:hover {
  text-decoration: underline;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}


.sectionTitle {
    margin: 0;
}


.question-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}


.question-group {
    background: white;
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    padding: 12px;
}


.question-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}


.question-group-fields {
    display: grid;
    grid-template-columns:
        2fr
        1fr
        1fr;
    gap: 10px;
}


.question-group-fields
.input-group {
    margin-bottom: 0;
}


.group-total {
    margin-top: 8px;
    font-size: 13px;
    color: #555;
}


.add-question-type-btn {
    width: 100%;
    margin-top: 10px;
    padding: 9px;
    border: 1px dashed #4facfe;
    background: white;
    color: #2563eb;
    border-radius: 7px;
    cursor: pointer;
}


.remove-question-type-btn,
.remove-section-btn {
    border: none;
    background: transparent;
    cursor: pointer;
}


.remove-question-type-btn {
    color: #dc2626;
}


.remove-section-btn {
    color: #dc2626;
}


@media (max-width: 650px) {

    .question-group-fields {
        grid-template-columns: 1fr;
    }

}

.loading {
  display: none;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
  padding: 15px;
  background: #f7f9fc;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  color: #333;
  text-align: left;
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #dfe3e8;
  border-top: 3px solid #4facfe;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

#generationStatus {
  margin-top: 4px;
  font-size: 13px;
  color: #666;
  font-weight: normal;
}

#generationElapsed {
  margin-top: 4px;
  font-size: 13px;
  color: #4facfe;
  font-weight: bold;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}


/* ============================================================
   DAY 18 — MOBILE RESPONSIVENESS
   Main exam-generation page
   ============================================================ */

/* Prevent padding and borders from causing overflow */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
}

body {
    min-width: 320px;
}

/* Keep the main form within the available screen width */
.container {
    width: calc(100% - 32px);
    max-width: 600px;
    margin: 32px auto;
}

.form-card {
    width: 100%;
    min-width: 0;
}

/* Do not stretch checkbox controls like text inputs */
input[type="checkbox"] {
    width: auto;
    max-width: 100%;
    flex-shrink: 0;
    cursor: pointer;
}

/* Allow long labels and controls to shrink safely */
.input-group,
.question-group,
.question-group-fields,
.section {
    min-width: 0;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

input[type="file"] {
    width: 100%;
    min-width: 0;
}

/* Medium screens: tablets and smaller laptops */
@media (max-width: 768px) {
    .navbar {
        padding: 14px 20px;
        flex-wrap: wrap;
        gap: 14px;
    }

    .logo {
        font-size: 21px;
    }

    .nav-links {
        gap: 18px;
        flex-wrap: wrap;
    }

    .auth-buttons {
        gap: 8px;
        flex-wrap: wrap;
    }

    .auth-buttons button {
        padding: 10px 14px;
    }

    .container {
        margin-top: 24px;
    }

    .form-card {
        padding: 20px;
    }

    .row {
        flex-direction: column;
        gap: 0;
    }

    .question-group-fields {
        grid-template-columns: 1fr;
    }
}

/* Phones */
@media (max-width: 480px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
    }

    .logo {
        text-align: center;
        font-size: 20px;
    }

    .nav-links {
        justify-content: center;
        gap: 12px 18px;
    }

    .auth-buttons {
        display: flex;
        width: 100%;
    }

    .auth-buttons button {
        flex: 1;
        min-width: 0;
        padding: 10px 8px;
    }

    .container {
        width: calc(100% - 24px);
        margin: 20px auto;
    }

    .container > h1 {
        font-size: 25px;
        line-height: 1.25;
    }

    .subtitle {
        font-size: 14px;
    }

    .form-card {
        padding: 14px;
        border-radius: 10px;
    }

    .form-card h3 {
        font-size: 18px;
    }

    .input-group label {
        line-height: 1.45;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .section {
        padding: 10px;
    }

    .section-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .question-group {
        padding: 10px;
    }

    .toggle-box {
        gap: 12px;
        align-items: center;
    }

    .toggle-box label {
        flex: 1;
        min-width: 0;
    }

    .btn {
        font-size: 15px;
        padding: 12px 10px;
        overflow-wrap: anywhere;
    }

    .loading {
        padding: 12px;
        gap: 10px;
    }

    #generationStatus,
    #generationElapsed {
        overflow-wrap: anywhere;
    }

    #downloadLink {
        display: inline-block;
        max-width: 100%;
        overflow-wrap: anywhere;
    }
}


/* Mobile sizing improvement */
@media (max-width: 600px) {
    body {
        font-size: 16px;
    }

    .container {
        width: calc(100% - 20px);
        max-width: none;
        margin: 16px auto;
    }

    .form-card {
        padding: 18px;
    }

    .container > h1 {
        font-size: 28px;
    }

    /* Give the four main controls more room */
    .row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .row .input-group {
        min-width: 0;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        min-width: 0;
    }

    .btn,
    button {
        min-height: 44px;
    }

    .toggle-box {
        justify-content: flex-start;
        gap: 12px;
    }
}


/* Keep the complete navigation header visible */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 2000;
    background: #fff;
}

/* Prevent the page content from hiding behind the fixed header */
body {
    padding-top: 80px;
}