* {
  padding: 0px;
  margin: 0px;
  box-sizing: border-box;
}

nav {
  height: 7vh;
  width: 100vw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #dfd6d6;
}

.nav-right {
  gap: 15%;
  display: flex;
  align-items: center;
  width: 15%;
}

.logo {
  font-size: 30px;
  font-weight: 800;
  margin-left: 25px;
  width: 10%;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 20px;
}

.nav-links li a {
  text-decoration: none;
  color: black;
  font-weight: 600;
  transition: color 0.3s;
}

.nav-links li a:hover {
  color: #0077cc;
}

.menu-toggle {
  display: none;
  font-size: 24px;
  cursor: pointer;
  margin-right: 20px;
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    right: 20px;
    background: #dfd6d6;
    flex-direction: column;
    padding: 15px;
    border-radius: 8px;
    width: 150px;
  }

  .nav-links.active {
    display: flex;
  }

  .menu-toggle {
    display: block;
  }
}

.container {
  display: flex;
  justify-content: center;
  width: 100vw;
  height: 93vh;

  /* background-color: crimson; */
}

.code {
  width: 50%;
  height: auto;
  overflow-y: scroll;
  overflow-x: hidden;
}

/* For Webkit browsers (Chrome, Safari) */
.code::-webkit-scrollbar {
  width: 8px; /* scrollbar width */
}

.code::-webkit-scrollbar-thumb {
  background-color: darkgray;
  border-radius: 4px;
}

.code::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

/* Output frame base styles */
#outputFrame {
  /* previous invalid rule removed */
}

.output {
  width: 50%;
  display: flex;
  flex-direction: column;
  border: 2px solid #555;
  box-sizing: border-box;
  overflow: auto;
}

.code-input {
  width: 100%;
  height: 47%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  margin: 20px 0px 0px 25px;
}

.textarea {
  height: 90%;
  width: 90%;
  font-size: 20px;
  resize: none;
  margin-bottom: 10px;
  border: 1px solid gray;
}

.dark-mode nav {
  background-color: #333;
  color: white;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  background: #fff;
  margin: 10% auto;
  padding: 20px;
  width: 50%;
  border-radius: 10px;
  text-align: center;
  position: relative;
}

.modal-content h2 {
  margin-bottom: 10px;
}

.modal-content p {
  font-size: 14px;
  line-height: 1.6;
}

.close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 24px;
  cursor: pointer;
}

/* ==============================
   📱 Mobile View (max-width: 300-600px)
   ============================== */
@media (min-width: 300px) and (max-width: 600px) {
  nav {
    display: flex;
    width: 100%;
    justify-content: space-around;
  }
  .logo {
    font-size: 20px;
    width: 100px;
    margin-left: 0px;
  }

  .nav-right {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 120px;
  }

  .container {
    flex-direction: column;
    padding: 10px;
    height: 93vh; /* keep total height */
  }

  .code, .output {
    width: 100%;
    flex: 1 1 50%;
  }

  .code-input {
    width: 100%;
    height: 40vh;
    margin: 30px auto 15px; /* center like output */
  }

  .output {
    margin-top: 15px;
    flex: 1 1 50%; /* same height portion as inputs container */
    display: flex;
    flex-direction: column;
  }

  .output > p {
    width: 90%;
    margin: 0 auto; /* same inner width as editors and iframe */
  }

  #outputFrame {
    width: 90%;   /* same as editors' inner area */
    height: 100%;
    margin: 0 auto; /* center like inputs */
  }

  .modal-content {
    width: 90%;
    margin: 30% auto;
  }
}

/* 📱 Mobile View (max-width: 600px) */
/* @media (max-width: 600px) {
  nav {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
    align-items: center;
  }

  .nav-right {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-left: 10px!;
  }

  .container {
    flex-direction: column;
    padding: 10px;
  }

  .code {
    width: 100%;
  }

  .code-input {
    width: 100%;
    height: 40vh;
    margin-top: 30px;
    margin-bottom: 15px;
  }

  .output {
    width: 100%;
    height: 300px;
    margin-top: 15px;
  }

  .modal-content {
    width: 90%;
    margin: 30% auto;
  }
} */

/* 📲 Tablet View (601px - 900px) */
@media (min-width: 601px) and (max-width: 900px) {
  nav {
    padding: 10px 20px;
    display: flex;
    justify-content: space-around;
  }

  .nav-right img {
    width: 28px;
    height: 28px;
  }

  .container {
    flex-direction: column;
    padding: 15px;
    height: 93vh; /* keep total height */
  }

  .code, .output {
    width: 100%;
    display: block; /* stack like mobile */
    flex: 1 1 50%;
  }

  .code-input {
    width: 100%;
    height: 40vh;
    margin: 30px auto 15px; /* center like output */
  }

  .output {
    margin-top: 15px;
    flex: 1 1 50%; /* same height portion as inputs container */
    display: flex;
    flex-direction: column;
  }

  .output > p {
    width: 90%;
    margin: 0 auto;
  }

  #outputFrame {
    width: 90%;   /* match input area width */
    height: 100%;
    margin: 0 auto;
  }

  .modal-content {
    width: 80%;
  }
}

/* ✅ For screens below 900px: show output at the top */
@media (max-width: 900px) {
  .container {
    flex-direction: column;
  }

  .output {
    order: -1; /* Move output above editors */
  }

  .code {
    order: 1;
  }

  /* 👉 Output frame: scroll + 4-side border on small screens */
  #outputFrame {
    border: 2px solid #555;
    box-sizing: border-box;
    overflow: auto;
  }
}
