/* Completion Modal Styles */
#completion-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInModal 0.3s;
}
.completion-modal-content {
  background: #fffbe8;
  border-radius: 22px;
  padding: 36px 32px 28px 32px;
  box-shadow: 0 8px 32px #0002, 0 2px 8px #0001;
  text-align: center;
  max-width: 90vw;
  min-width: 260px;
  position: relative;
  font-family: inherit;
}
.completion-modal-content h2 {
  color: #1e40af;
  margin-bottom: 0.5em;
  font-size: 2.1em;
}
.completion-modal-content p {
  color: #333;
  font-size: 1.15em;
  margin-bottom: 1.2em;
}
.close-modal {
  position: absolute;
  top: 12px;
  left: 18px;
  font-size: 2em;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
}
.close-modal:hover {
  color: #c00;
}
@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}
/* Top bar row for menu and status */
.top-bar-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  width: 100%;
  /* padding: 0 20px; */
}
.menu-toggle {
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 10px 22px;
  font-size: 1.08em;
  font-weight: 500;
  box-shadow: 0 1px 4px #217a4a22;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  margin-left: 0;
  margin-right: 10px;
}
.menu-toggle:hover {
  background: #1e3a8a;
  box-shadow: 0 2px 8px #217a4a33;
}



body {
  min-height: 100vh;
  margin: 0;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  background: #bdcbdf;
  direction: rtl;
  height: 100vh;
}

.container {
  display: flex;
  flex-direction: row;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.exercise {
  font-size: 1.15em;
  padding: 10px 24px 24px 24px;
  margin: 10px auto;
  max-width: 1100px;
  width: 100%;
  min-width: 320px;
  transition: box-shadow 0.2s;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.code-area {
  background: #232a3a;
  color: #e0e7ff;
  font-size: 0.9em;
  border-radius: 30px;
  padding: 20px 16px;
  margin-bottom: 24px;
  min-height: 60px;
  display: block;
  white-space: pre-line;
  min-width: 320px;
  max-width: 420px;  
  width: 100%;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1.5px 4px rgba(0,0,0,0.12);
}

.code-area select,
.code-area input {
  font-size: 1em;
  margin: 0 3px 8px 3px;
  min-width: 70px;
  padding: 6px 10px;
  box-sizing: border-box;
  background: #817979;
  border: 2px solid #636060;
  border-radius: 8px;
  color: #f5f5f5;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-area select:focus,
.code-area input:focus {
  border-color: #0a84ff;
  box-shadow: 0 0 5px rgba(10, 132, 255, 0.5);
  outline: none;
}

.run-btn {
  padding: 12px 18px;
  background: #0a84ff;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 1em;
  cursor: pointer;
  margin-bottom: 10px;
  margin-top: 2px;
  transition: background 0.2s;
}

.run-btn:hover {
  background: #005bb5;
}
.image-container {
  overflow: hidden;
  position: relative;
  display: inline-block;
  width: 100%;
  aspect-ratio: 414 / 347;
  
}

.main-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-img {
  width: 100%;
  max-width: 350px;
  min-width: 260px;
  aspect-ratio: 414 / 347;
  border-radius: 20px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  color: #888;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1.5px 4px rgba(0,0,0,0.12);

}

.result-img.animate {
  animation: highlightFlash 0.4s ease-in-out;
}

@keyframes highlightFlash {
  0% { box-shadow: 0 0 0px rgba(10,132,255,0.0); }
  50% { box-shadow: 0 0 12px rgba(10,132,255,0.4); }
  100% { box-shadow: 0 0 0px rgba(10,132,255,0.0); }
}

.level-btn {
  background: #dbe0e7;
  color: #1e40af; 
  border: none; 
  font-weight: 500;
  box-shadow: none;
  transition: background 0.2s, color 0.2s;
  padding: 12px 32px;
  min-width: 120px;
  font-size: 1.08em;
  margin-bottom: 0;
  margin-top: 0;
  border-radius: 0 50px 50px 0; 
}

.level-btn:last-child {
  border-radius: 50px 0 0 50px; 
}

.level-btn.selected {
  background: #45568b;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 6px rgba(30, 64, 175, 0.3);
}
.level-btn:hover {
  background: #168686;
  color: #fff;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

.answer-msg {
  margin: 12px 10px;
  font-weight: bold;
  text-align: center;
}

.answer-msg.success {
  color: #1a7f37;
}

.answer-msg.error {
  color: #c00;
} 

@media (max-width: 900px) {
  .container {
    flex-direction: column;
    display: block;
  }

  .exercise {
    max-width: 98vw;
    padding: 18px 4vw;
  }

  .result-img {
    width: 98vw;
    max-width: 290px;
  }

  .level-btn {
    padding: 10px 20px;
    min-width: 90px;
    font-size: 1em;
    margin-bottom: 0;
    margin-top: 0;
  }

  .code-area {
    font-size: 0.8em;
  }

  .run-btn {
    font-size: 0.9em;
  }
}

@media (max-width: 700px) {
  .exercise {
    min-width: 0;
    max-width: 90vw;
    padding: 10px 2vw;
  }

  .code-area {
    max-width: 400px; 
    padding: 14px 2vw;
  }
}

@media (max-width: 600px) {
  .exercise {
    padding: 10px 2vw;
    max-width: 90vw;
  }

  .code-area {
    max-width: 400px; 
    min-width: 0;
    box-sizing: border-box;
    padding: 14px 2vw;
  }

  .result-img {
    width: 99vw;
    max-width: 290px;
  }
}

.exercise h3 {
  font-size: 2rem;
  color: #3a5a98;
  margin-bottom: 0.5em;
  margin-top: 0;
  text-align: center;
  letter-spacing: 1px;
}

.exercise-description {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 1.5em;
  text-align: center;
  line-height: 1.5;
}

#level-selector {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 10px;
}

.user-status-bar {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  margin: 0 10px;
  font-size: 1.08em;
}

#loginStatus {
  background: #d4d6dd;
  color: #3a5a98;
  padding: 7px 18px;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: 0 1px 4px #3a5a9811;
  letter-spacing: 0.5px;
}

#logoutBtn {
  background: #3579bd;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 7px 22px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: none;
}

#logoutBtn:hover {
  background: #005bb5;
  box-shadow: none;
}

.exercise-flex-wrap {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  width: 100%;
}

.code-wrap {
  flex: 1 1 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 293px;
  box-sizing: border-box;
}

.code-wrap .run-btn {
  align-self: center;
  width: auto !important;
  min-width: 0 !important;
  display: inline-block !important;
}

@media (max-width: 900px) {
  .exercise-flex-wrap {
    flex-direction: column;
    gap: 0;
    align-items: center;
  }

  .code-wrap {
    max-width: 100%;
    width: 100%;
    min-height: unset;
    justify-content: flex-start;
  }

  .user-status-bar {
    position: static;
    font-size: 0.9em;
  }

  .exercise h3 {
    font-size: 1.4rem;
    margin-bottom: 0.3em;
  }
}


/* Mobile exercise navigation buttons */
.exercise-nav-mobile {
  display: none;
}
.exercise-nav-btn {
  background: #e4c239;
  color: #03180d;
  border: none;
  border-radius: 24px;
  padding: 10px 28px;
  font-size: 1.08em;
  font-weight: 500;
  box-shadow: 0 1px 4px #217a4a22;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.exercise-nav-btn:hover {
  background: #d2ae1e;
  color: #fff;
  box-shadow: 0 2px 8px #217a4a33;
}

@media (max-width: 900px) {
  .exercise-nav-mobile {
    display: flex !important;
    justify-content: center;
    gap: 18px;
    margin: 18px 0 8px 0;
  }
}