@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap");

body {
  background-image: url("../assets/background-landing.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  opacity: 0.95;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Lexend", sans-serif;
}

/* Island (original absolute layout) */
.island {
  position: absolute;
  width: 90%;
  max-width: 1400px;
  aspect-ratio: 14 / 5.5;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.8);
  border: 3px solid #ffffff;
  box-shadow: inset 0px -3px 13.1px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  border-radius: 12px;
}

/* island: two-panel card (left login, right carousel) */
.island.login {
  position: absolute;
  width: 100%;
  max-width: 1800px;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  align-items: center;
  padding: 26px;
  background: rgba(213, 214, 227, 0.8);
  border-radius: 18px;
  border: none;
  backdrop-filter: blur(2px);

  box-shadow: inset 0px -3px 13.1px rgba(0, 0, 0, 0.25);
}

/* left panel: login area */
.panel-left {
  flex: 0 0 40%;
  padding: 2px 30px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background: #bdc6e046;
  border: none;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(45, 51, 107, 0.08);
}

/* right panel: carousel */
.panel-right {
  flex: 1 1 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

/* title */
.login-title {
  font-size: 36px;
  color: #2d336b;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 45px; /* increased gap to the email field */
  padding-top: 23px;
}

/* form layout */
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 41px; /* increased gap between email and password textbox */
  top: 50px;
}

/* Error alert styling */
.error-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background-color: #fee;
  border: 1px solid #f99;
  border-radius: 8px;
  color: #c33;
  font-size: 14px;
  font-weight: 500;
}

.error-alert i {
  font-size: 18px;
  flex-shrink: 0;
}

/* fields (look like mockup) */
.field {
  height: 56px;
  width: 350px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  gap: 12px;
  padding: 0 14px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(20, 28, 60, 0.09);
  border: 1px solid rgba(0, 0, 0, 0.03);
  overflow: hidden;
}
.field .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(45, 51, 107, 0.06);
  color: #2d336b;
  font-size: 16px;
}
.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: "Lexend", sans-serif;
  font-size: 15px;
  color: #333;
  padding: 6px 8px;
}

/* Password field specific: no icon layout */
.field.password-field {
  padding: 0;
}
.field.password-field input {
  width: 100%;
  padding: 0 45px 0 14px;
}

/* Forgot password: aligned to right edge of password box, below it */
.forgot-pass {
  position: relative;
  align-self: flex-end;
  width: auto;
  max-width: 100%;
  margin: -17px 0 8px 0; /* net gap becomes 24px (login-form gap 41px + -17px) */
  font-family: "Lexend", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #333333;
  text-align: right;
  text-decoration: none;
  cursor: pointer;
}

/* sign-in button */
.btn-signin {
  width: 100%;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(90deg, #2d336b 0%, #7886c7 100%);
  color: #fff;
  border: none;
  font-family: "Lexend", sans-serif;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(45, 51, 107, 0.12);
}

/* Inline client-side error used on reset password page */
#clientError,
.alert.error {
  display: none; /* toggled via JS */
  padding: 10px 12px;
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 0.95rem;
  box-shadow: 0 6px 14px rgba(31, 44, 108, 0.04);
}

@media (max-width: 600px) {
  #clientError,
  .alert.error {
    font-size: 0.95rem;
    margin-top: 10px;
  }
}

/* divider + register */
.divider {
  height: 2px;
  width: 70%;
  background: rgba(0, 0, 0, 0.06);
  margin: -10px 50px -15px;
}
.register-link {
  font-size: 14px;
  color: #333;
  text-decoration: none;
  text-align: center;
}

/* Carousel on the right */
.carousel {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 420px; /* desktop visual limit (was height: 420px) */
  border-radius: 12px;
  overflow: hidden;
  background: #eee;
  box-shadow: 0 8px 24px rgba(8, 10, 25, 0.06);
  position: relative; /* ensure contained in panel-right */
}
.carousel .slides {
  display: flex;
  height: 100%;
  transition: transform 0.6s;
}
.carousel .slide {
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
}
.carousel .slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* carousel controls & indicators reuse existing styles; adjust positions if needed */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-btn.prev {
  left: 12px;
}
.carousel-btn.next {
  right: 12px;
}
.carousel-indicators {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 30;
}
.carousel-indicators .indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  border: none;
}
.carousel-indicators .indicator.active {
  background: #2d336b;
}

/* Responsive: original stacking behaviour */
@media (max-width: 900px) {
  .island {
    flex-direction: column;
    gap: 20px;
    padding: 24px;
  }
  /* On tablet and below we hide the carousel and make the login card full-width */
  .panel-right {
    display: none !important;
  }
  .carousel {
    display: none !important;
  }
  .textbox_user,
  .textbox_pass,
  .forgot-pass,
  .btn-signin {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: 100%;
    max-width: 680px;
    margin-left: 0;
    margin-bottom: 12px;
  }
  .forgot-pass {
    text-align: right;
    padding-right: 6px;
    width: 100%;
    margin-left: 0;
  }
}

/* Slightly tighter spacing for phones */
@media (max-width: 480px) {
  .island {
    padding: 16px;
    gap: 12px;
  }
  .carousel {
    aspect-ratio: 1 / 1;
    max-height: 180px;
  }
  .textbox_user,
  .textbox_pass {
    height: 52px;
    margin-bottom: 12px;
  }
  .btn-signin {
    height: 50px;
    margin-top: 8px;
  }
}

/* Unified centered island with fixed desktop size and responsive fallback */
.island,
.island.login {
  position: absolute;
  /* desktop size: consistent and centered both horizontally and vertically */
  width: 1100px;
  max-width: calc(100% - 40px);
  height: 600px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 28px;
  align-items: stretch;
  padding: 26px;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 18px;
  border: none;
  box-shadow:
    0 10px 30px rgba(12, 18, 40, 0.06),
    inset 0 -2px 10px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  z-index: 2;
}

/* Mobile override: when viewport is narrow, make island flow naturally, no fixed height, carousel hidden */
@media (max-width: 900px) {
  .island,
  .island.login {
    position: relative !important;
    width: calc(100% - 32px) !important;
    max-width: 760px !important;
    height: auto !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: block !important;
    margin: 28px auto !important;
    padding: 20px !important;
    overflow: visible !important;
  }

  .panel-left {
    flex: 1 1 100% !important;
    width: 100% !important;
    padding: 18px !important;
    display: block !important;
  }

  /* increase touch targets and ensure the form centers */
  .login-form {
    gap: 18px;
  }
  .field {
    width: 100%;
    max-width: 100%;
  }
  .login-title {
    font-size: 26px;
    margin-bottom: 18px;
  }
}

/* left panel: keep proportion */
.panel-left {
  flex: 0 0 40%;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* right panel: let carousel take remaining area and fill vertically */
.panel-right {
  flex: 1 1 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

/* make the carousel fill the panel and enlarge */
.carousel {
  width: 100%;
  aspect-ratio: 16 / 9; /* keep 16:9 when filling the panel */
  height: auto;
  max-height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #eee;
  box-shadow: 0 8px 24px rgba(8, 10, 25, 0.06);
  position: relative;
}

/* Force carousel to be perfectly square (1:1) and make images cover it */
.panel-right .carousel {
  width: 100%;
  max-width: 640px; /* optional: limit max size */
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1; /* modern browsers */
  background: #f3f3f3;
}

/* Fallback for older browsers: create a square via padding-top */
.panel-right .carousel::before {
  content: "";
  display: block;
  padding-top: 100%; /* forces 1:1 when aspect-ratio unsupported */
}

/* Slide layout fills the square */
.panel-right .carousel .slides {
  display: flex;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.45s ease;
  will-change: transform;
}
.panel-right .carousel .slide {
  flex: 0 0 100%;
  height: 100%;
  box-sizing: border-box;
}

/* Make images fill the slide and preserve center crop */
.panel-right .carousel .slide img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* preserves aspect, crops edges if needed */
  object-position: center;
  display: block;
}

/* Optional: reduce max size on small screens */
@media (max-width: 700px) {
  .panel-right .carousel {
    max-width: 420px;
  }
}

/* Responsive: smaller screens stack and use a shorter island */
@media (max-width: 1100px) {
  .island,
  .island.login {
    width: calc(100% - 40px);
    height: auto;
    top: 8%;
    transform: translateX(-50%);
    left: 50%;
    flex-direction: column;
    padding: 22px;
  }
  .panel-left {
    flex: none;
    width: 100%;
    padding: 12px;
  }
  .panel-right {
    flex: none;
    width: 100%;
    padding: 0;
  }
  .carousel {
    aspect-ratio: 1 / 1;
    max-height: 440px;
    border-radius: 10px;
  }
}

/* Keep smaller phone breakpoint adjustments (unchanged) */
/* ...existing code... */

/* responsive: stack panels on smaller screens */
@media (max-width: 900px) {
  .island.login {
    flex-direction: column;
    width: 360px;
    padding: 22px;
    gap: 18px;
    left: 50%;
    transform: translateX(-50%);
  }
  .panel-left {
    padding: 8px 12px;
  }
  .panel-right {
    padding: 0;
  }
  .carousel {
    aspect-ratio: 1 / 1;
    max-height: 420px;
    border-radius: 10px;
  }
  .login-title {
    font-size: 40px;
    margin-bottom: 14px;
  }
  .field {
    height: 52px;
    border-radius: 10px;
  }
  .btn-signin {
    height: 56px;
  }
}

.back-button {
  position: absolute;
  /* Default position (for desktop) */
  top: 40px;
  left: 40px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;

  background: rgba(45, 51, 107, 0.08); /* Subtle background from theme */
  color: #2d336b; /* Main theme color */

  border-radius: 50%; /* Circular shape */
  text-decoration: none;
  font-size: 16px;

  transition: background 0.2s ease;
  z-index: 10;
}

.back-button:hover {
  background: rgba(45, 51, 107, 0.15); /* Slightly darker on hover */
}

/* 2. Adjust button position for tablet/smaller screens */
@media (max-width: 1100px) {
  .back-button {
    top: 20px; /* Aligns with 22px padding */
    left: 20px; /* Aligns with 22px padding */
    width: 38px;
    height: 38px;
  }
}

/* 3. Adjust button position for mobile screens */
@media (max-width: 480px) {
  .back-button {
    top: 12px; /* Aligns with 16px padding */
    left: 12px; /* Aligns with 16px padding */
  }
}

.login-form {
  /* We adjust the gap slightly to make room */
  gap: 36px;
}

.forgot-pass {
  /* Adjust margin for new gap */
  margin: -16px 0 8px 0;
}

.divider {
  /* Adjust margins for new gap */
  margin: -12px 50px -12px;
}

.register-link {
  /* Pull up slightly */
  margin-top: -10px;
}

/* The new container for role-switching links */
.login-as-options {
  text-align: center;
  margin-top: -5px; /* Pulls it closer to the register link */
  font-size: 14px;
  color: #555;
}

.login-as-options span {
  margin-right: 8px;
}

.login-as-options a {
  color: #2d336b; /* Use the main theme color */
  text-decoration: none;
  font-weight: 500;
  margin: 0 4px;
}

.login-as-options a:hover {
  text-decoration: underline;
}

/* Center wrapper used by single-panel pages like forgot/reset */
.center-wrapper {
  min-height: 100vh; /* fill viewport */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: transparent;
}

/* Small explanatory guide shown above forms */
.message-guide {
  max-width: 520px;
  color: #333;
  font-size: 15px;
  line-height: 1.45;
  margin: 8px 0 18px 0;
  text-align: left;
}

/* Make the single panel narrower for forgot/reset pages */
.center-wrapper .island.login {
  /* act like a centered card: limit height and allow internal scrolling to prevent content overflow */
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 740px;
  max-width: calc(100% - 40px);
  height: auto;
  max-height: 90vh;
  min-height: 520px;
  padding: 22px 20px;
  overflow: visible;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Ensure panel-left centers content on single-panel pages */
.center-wrapper .panel-left {
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
}

.reset-title {
  font-size: 32px;
  color: #2d336b;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin: 5px 0 20px 0;
  padding-top: 10px;
}

/* Strong mobile override: ensure the login card is a simple centered single column
   layout on small phones. Placed at the end to override previous conflicting rules. */
@media (max-width: 420px) {
  /* make background static on mobile for performance/readability */
  body {
    background-attachment: scroll;
    background-size: cover;
  }

  /* card container: centered, narrow, no absolute positioning */
  .island,
  .island.login {
    position: relative !important;
    width: calc(100% - 32px) !important;
    max-width: 420px !important;
    margin: 18px auto !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: block !important;
    padding: 16px !important;
    height: auto !important;
    border: none !important;
    overflow: visible !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 20px rgba(12, 18, 40, 0.06) !important;
    background: rgba(255, 255, 255, 0.94) !important;
  }

  /* hide carousel and right panel completely */
  .panel-right,
  .carousel {
    display: none !important;
  }

  /* left panel becomes full width with tighter padding */
  .panel-left {
    width: 100% !important;
    padding: 6px 8px !important;
    box-sizing: border-box;
    display: block !important;
  }

  /* title: center and scale down */
  .login-title {
    font-size: 28px !important;
    text-align: center !important;
    margin: 6px 0 18px 0 !important;
    padding-top: 6px !important;
  }

  /* make fields full-width and easier to tap */
  .field {
    width: 100% !important;
    height: 52px !important;
    padding: 0 12px !important;
    margin-bottom: 0px !important;
  }
  .field input {
    font-size: 16px !important;
  }

  .forgot-pass {
    margin: 0 0 12px 0 !important;
    font-size: 13px !important;
    margin-top: -10px !important;
  }

  .btn-signin {
    width: 100% !important;
    height: 50px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
  }

  /* back button: keep it visible but small and inset */
  .back-button {
    position: absolute !important;
    left: 12px !important;
    top: 12px !important;
    width: 36px !important;
    height: 36px !important;
    z-index: 20 !important;
  }

  /* reduce extra margins from other helpers */
  .divider {
    display: none !important;
  }
  .login-as-options {
    margin-top: 8px !important;
    font-size: 13px !important;
  }
}
