/* ===== RESPONSIVE SCROLLABLE LOGIN WITH ACCESSIBLE SIGNUP ===== */

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f8f9fa;
  color: #333;
  height: 100%;
  overflow: hidden; /* Prevent page scrolling on desktop */
  line-height: 1.6;
}

/* ===== DESKTOP DESIGN ===== */
.auth-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  background-color: #ffffff;
  position: relative;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* Logo */
.logo {
  position: absolute;
  top: 25px;
  left: 30px;
  font-weight: 700;
  font-size: 28px;
  color: #333;
  z-index: 100;
  text-decoration: none;
}

/* Desktop Form Area */
.auth-left {
  width: 55%;
  padding: 40px 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
  height: 100vh;
  position: relative;
}

/* Desktop Image Area */
.auth-right {
  width: 45%;
  background-image: url('/static/media/login.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  position: relative;
  height: 100vh;
  background-color: #f0f4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.auth-right::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(78, 110, 242, 0.08) 0%, rgba(78, 110, 242, 0.03) 100%);
  pointer-events: none;
}

/* Content Wrapper */
.content-wrapper {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

/* Form Styling */
.login-section {
  background: #ffffff;
  padding: 30px 25px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.08);
  width: 100%;
  position: relative;
  backdrop-filter: blur(10px);
  height: auto;
  /* overflow: hidden; Ensure container clips overflow */
  box-sizing: border-box;
  /* display: flex; */
  flex-direction: column;
}

/* Ensure tab container and content are properly contained */
.tab-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Important for flex children with overflow */
}

.login-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 4px;
  background: #333;
  border-radius: 40px 40px 0 0;
}

/* Typography */
h1 {
  font-size: 28px;
  margin-bottom: 15px;
  text-align: center;
  color: #333;
  font-weight: 700;
  line-height: 1.2;
}

.highlight {
  color: #4e6ef2;
  font-weight: 700;
}

/* Tab Navigation */
.tab-container {
  margin-top: 15px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tab-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1vh;
}

.tab-btn {
  background-color: #f8f9fa;
  padding: 12px 28px;
  border-radius: 50px;
  border: 2px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 15px;
  min-width: 130px;
  text-align: center;
  color: #666;
  position: relative;
}

.tab-btn:hover {
  background-color: #e9ecef;
  border-color: #4e6ef2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 110, 242, 0.15);
}

.tab-btn.active {
  background-color: #333;
  color: white;
  border-color: #4e6ef2;
  box-shadow: 0 6px 20px rgba(78, 110, 242, 0.3);
  transform: translateY(-2px);
}

/* Form Elements */
form {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 5px;
}

label {
  font-weight: 600;
  margin-top: 10px;
  margin-bottom: 6px;
  color: #333;
  font-size: 14px;
  letter-spacing: 0.5px;
}

input, select, textarea {
  padding: 12px 14px;
  border: 2px solid #e8ecef;
  border-radius: 12px;
  margin-bottom: 6px;
  width: 100%;
  font-size: 15px;
  background-color: #ffffff;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  color: #333;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: #4e6ef2;
  box-shadow: 0 0 0 4px rgba(78, 110, 242, 0.1);
  background-color: #ffffff;
  transform: translateY(-1px);
}

button, button[type="submit"] {
  padding: 14px 35px;
  background: #333;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
  align-self: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 20px rgba(78, 110, 242, 0.3);
  letter-spacing: 0.5px;
}

/* Signin button - centered on desktop only */
@media screen and (min-width: 769px) {
  #signin button, #signin button[type="submit"] {
    align-self: center;
    width: auto;
    min-width: 200px;
    max-width: 300px;
  }
}

button:hover {
  background: #333;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(78, 110, 242, 0.4);
}

/* Form Layout */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 5px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.full-width {
  grid-column: 1 / -1;
}

/* Form Cards (Admin/Customer forms) */
.form-card {
  padding: 0;
  margin: 0;
  width: 100%;
}

/* ===== SIGNUP SECTION REDESIGN - PROPERLY ALIGNED ===== */

/* Reset signup specific styles */
#signup {
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  margin: 0;
  background: transparent;
  width: 100%;
  box-sizing: border-box;
}

/* Role selector at top */
#signup > label:first-of-type {
  font-size: 14px;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 6px;
  color: #333;
  display: block;
}

#signup-role {
  width: 100%;
  padding: 12px;
  border: 2px solid #e8ecef;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  background: #ffffff;
  box-sizing: border-box;
}

/* Form cards proper alignment */
#admin-form, #customer-form {
  width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#admin-form form, #customer-form form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
}

/* Signup form elements */
#signup label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 4px;
  color: #333;
  display: block;
  width: 100%;
}

#signup input, 
#signup select, 
#signup textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e8ecef;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
  background: #ffffff;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

#signup input:focus, 
#signup select:focus, 
#signup textarea:focus {
  border-color: #4e6ef2;
  box-shadow: 0 0 0 3px rgba(78, 110, 242, 0.1);
  outline: none;
}

/* Form row layout - FIXED GRID */
#signup .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 0;
  width: 100%;
  box-sizing: border-box;
}

#signup .form-group {
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

#signup .full-width {
  grid-column: 1 / -1;
  width: 100%;
}

/* Textarea specific */
#signup textarea {
  min-height: 80px;
  resize: vertical;
}

/* Submit buttons */
#signup button[type="submit"] {
  width: 100%;
  padding: 14px;
  background: #333;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

#signup button[type="submit"]:hover {
  background: #333;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(78, 110, 242, 0.3);
}

/* Custom scrollbar */
#signup::-webkit-scrollbar {
  width: 6px;
}

#signup::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

#signup::-webkit-scrollbar-thumb {
  background: rgba(78, 110, 242, 0.3);
  border-radius: 10px;
}

#signup::-webkit-scrollbar-thumb:hover {
  background: rgba(78, 110, 242, 0.5);
}

/* ===== KEY FIX: MAKE SIGNUP CONTENT SCROLLABLE ===== */
/* Container of tab contents */
.tab-content {
  display: none;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  height: 100%;
}

/* Signin tab - no scroll needed */
#signin {
  overflow: visible;
}

/* Hidden form styling */
.form-card[style*="display: none"] {
  display: none !important;
}

.form-card[style*="display: block"] {
  display: block !important;
  width: 100%;
}

/* ===== TABLET RESPONSIVE (769px - 1023px) ===== */
@media screen and (min-width: 769px) and (max-width: 1023px) {
  .auth-left {
    width: 60%;
    padding: 40px 35px;
  }

  .auth-right {
    width: 40%;
    background-position: center center;
  }

  .content-wrapper {
    max-width: 450px;
  }

  .login-section {
    padding: 30px;
    border-radius: 16px;
  }

  h1 {
    font-size: 26px;
  }
  
  /* Adjust scrollable area for signup */
  #signup {
    max-height: 60vh;
  }
}

/* ===== MOBILE RESPONSIVE DESIGN (≤768px) - FIXED SCROLLING ===== */
@media screen and (max-width: 768px) {
  body, html {
    background-color: #f8f9fa;
    overflow-x: hidden; /* Prevent horizontal scroll */
    overflow-y: auto; /* Allow vertical scroll */
    height: auto; /* Allow body to expand */
    min-height: 100vh; /* Ensure minimum height */
  }

  .auth-container {
    flex-direction: column;
    min-height: 100vh; /* Use min-height instead of fixed height */
    height: auto; /* Allow container to expand */
    box-shadow: none;
    background-color: #f8f9fa;
    overflow: visible; /* Allow overflow for scrolling */
    position: relative;
  }

  /* MOBILE: Image Section First (Fixed Height) */
  .auth-right {
    width: 100%;
    height: 40vh; /* Fixed height for image area */
    background-size: cover;
    background-position: center center;
    background-color: #f0f4ff;
    background-repeat: no-repeat;
    order: 1;
    position: relative;
    border-radius: 0;
    box-shadow: none;
    margin-top: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0; /* Prevent shrinking */
  }

  .auth-right::after {
    background: linear-gradient(135deg, rgba(78, 110, 242, 0.08) 0%, rgba(78, 110, 242, 0.04) 100%);
    border-radius: 0;
  }

  /* MOBILE: Forms Section (Scrollable) */
  .auth-left {
    width: 100%;
    min-height: 60vh; /* Minimum height */
    height: auto; /* Allow expansion */
    padding: 0 20px 40px; /* Add bottom padding for scroll space */
    background-color: transparent;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    order: 2;
    z-index: 10;
    margin-top: -10vh; /* Overlap with image */
    overflow: visible; /* Allow content to overflow */
  }
  
  /* Mobile Content */
  .content-wrapper {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align to top */
    padding-top: 20px;
    padding-bottom: 40px; /* Add bottom padding */
  }

  /* Mobile Logo - Position on Image */
  .logo {
    position: absolute;
    top: 25px;
    left: 25px;
    font-size: 24px;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 50;
    font-weight: 700;
  }

  /* Mobile Login Section - Scrollable Content */
  .login-section {
    padding: 25px;
    background: #ffffff;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin: 0;
    width: 100%;
    position: relative;
    min-height: auto; /* Allow expansion */
    max-height: none; /* Remove height restriction */
    backdrop-filter: blur(20px);
    overflow: visible; /* Allow content to be visible */
  }

  .login-section::before {
    height: 4px;
    border-radius: 25px 25px 0 0;
  }
  
  /* Mobile Typography */
  h1 {
    font-size: 22px;
    text-align: center;
    margin-bottom: 10px;
    color: #333;
    margin-top: 0;
    line-height: 1.3;
  }

  /* Mobile Tab Navigation */
  .tab-container {
    margin-top: 12px;
    overflow: visible; /* Allow tab content to be visible */
  }

  .tab-content {
    overflow: visible; /* Allow content to expand */
    height: auto; /* Allow dynamic height */
    min-height: auto; /* Remove minimum height restriction */
  }

  .tab-content.active {
    height: auto; /* Dynamic height for active content */
  }

  .tab-nav {
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    margin-top: 1vh;
  }

  .tab-btn {
    flex: 1;
    min-width: 115px;
    max-width: 145px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 50px;
  }

  .tab-btn.active {
    transform: translateY(-1px);
  }

  /* Mobile signin section - ensure button is visible */
  #signin {
    overflow: visible; /* Allow signin content to be visible */
    height: auto; /* Dynamic height */
    min-height: auto; /* Remove height restrictions */
  }

  /* Mobile signup adjustments - PROPERLY SCROLLABLE */
  #signup {
    max-height: none; /* Remove height restriction */
    height: auto; /* Allow dynamic height */
    width: 100%;
    overflow: visible; /* Make content visible */
    padding-bottom: 20px; /* Add bottom padding */
  }

  /* Single column layout on mobile */
  #signup .form-row {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 0;
    width: 100%;
  }

  #signup .form-group {
    width: 100%;
    margin-bottom: 0;
  }

  #signup input, 
  #signup select, 
  #signup textarea {
    width: 100%;
    padding: 12px;
    font-size: 16px; /* Prevent zoom on iOS */
    margin-bottom: 10px;
    box-sizing: border-box;
  }

  #signup label {
    font-size: 14px;
    margin-top: 8px;
    margin-bottom: 4px;
    width: 100%;
  }

  #signup textarea {
    min-height: 60px;
  }

  #signup button[type="submit"] {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 15px;
    margin-bottom: 20px; /* Add bottom margin */
    box-sizing: border-box;
  }

  #signup-role {
    width: 100%;
    font-size: 16px;
    margin-bottom: 15px;
  }

  /* Mobile Button - ensure visibility */
  button, button[type="submit"] {
    width: 100%;
    padding: 14px 22px;
    font-size: 16px;
    border-radius: 12px;
    margin-top: 18px;
    margin-bottom: 20px; /* Add bottom margin for accessibility */
  }

  /* Mobile Labels */
  label {
    font-size: 14px;
    margin-top: 8px;
    margin-bottom: 4px;
  }
}

/* ===== SMALL MOBILE (≤480px) ===== */
@media screen and (max-width: 480px) {
  .auth-right {
    height: 35vh;
  }

  .auth-left {
    min-height: 65vh; /* Minimum height */
    height: auto; /* Allow expansion */
    padding: 0 15px 40px; /* Increase bottom padding */
    margin-top: -10vh;
  }

  .content-wrapper {
    max-width: 100%;
    padding-top: 15px;
    padding-bottom: 40px; /* Add bottom padding */
  }

  .logo {
    font-size: 22px;
    top: 20px;
    left: 20px;
  }

  .login-section {
    padding: 20px;
    border-radius: 20px;
    max-height: none; /* Remove height restriction */
    min-height: auto; /* Allow dynamic height */
  }

  h1 {
    font-size: 20px;
    margin-bottom: 8px;
  }

  /* Small mobile signup adjustments - PROPERLY SCROLLABLE */
  #signup {
    max-height: none; /* Remove height restriction */
    height: auto; /* Allow dynamic height */
    width: 100%;
    overflow: visible; /* Make content visible */
    padding-bottom: 30px; /* Add more bottom padding */
  }

  #signup .form-row {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 0;
    width: 100%;
  }

  #signup .form-group {
    width: 100%;
  }

  #signup input, 
  #signup select, 
  #signup textarea {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    margin-bottom: 8px;
    box-sizing: border-box;
  }

  #signup label {
    font-size: 13px;
    margin-top: 6px;
    margin-bottom: 3px;
    width: 100%;
  }

  #signup textarea {
    min-height: 50px;
  }

  #signup button[type="submit"] {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    margin-top: 12px;
    margin-bottom: 30px; /* Add more bottom margin */
    box-sizing: border-box;
  }

  #signup-role {
    width: 100%;
    padding: 10px;
    font-size: 15px;
  }

  .tab-btn {
    min-width: 105px;
    padding: 10px 16px;
    font-size: 13px;
  }
  
  input, select, textarea {
    padding: 10px 12px;
    font-size: 15px;
    margin-bottom: 5px;
  }

  button, button[type="submit"] {
    padding: 12px 18px;
    font-size: 15px;
    margin-top: 15px;
    margin-bottom: 30px; /* Add bottom margin */
  }
  
  label {
    font-size: 13px;
    margin-top: 6px;
    margin-bottom: 3px;
  }
}

/* ===== LANDSCAPE MOBILE ORIENTATION ===== */
@media screen and (max-width: 768px) and (orientation: landscape) {
  body, html {
    overflow-y: auto; /* Ensure scrolling works in landscape */
  }

  .auth-container {
    flex-direction: row;
    min-height: 100vh;
    height: auto; /* Allow expansion */
  }
  
  .auth-right {
    width: 40%;
    height: 100vh;
    order: 2;
  }
  
  .auth-left {
    width: 60%;
    height: auto; /* Allow expansion */
    min-height: 100vh;
    margin-top: 0;
    order: 1;
    padding: 15px;
    overflow-y: auto; /* Enable vertical scrolling */
  }
  
  .login-section {
    max-height: none; /* Remove height restriction */
    min-height: auto; /* Allow dynamic height */
    padding: 15px;
    margin-bottom: 20px; /* Add bottom margin */
  }

  /* Landscape signup adjustments - PROPERLY SCROLLABLE */
  #signup {
    max-height: none; /* Remove height restriction */
    height: auto; /* Allow dynamic height */
    width: 100%;
    overflow: visible; /* Make content visible */
    padding-bottom: 20px; /* Add bottom padding */
  }

  /* Two column layout in landscape if space allows */
  #signup .form-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 0;
    width: 100%;
  }

  #signup .form-group {
    width: 100%;
  }

  #signup input, 
  #signup select, 
  #signup textarea {
    width: 100%;
    padding: 8px;
    font-size: 14px;
    margin-bottom: 6px;
    box-sizing: border-box;
  }

  #signup label {
    font-size: 12px;
    margin-top: 4px;
    margin-bottom: 2px;
    width: 100%;
  }

  #signup textarea {
    min-height: 50px;
  }

  #signup button[type="submit"] {
    width: 100%;
    padding: 8px;
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 20px; /* Add bottom margin */
    box-sizing: border-box;
  }

  #signup-role {
    width: 100%;
    padding: 8px;
    font-size: 14px;
  }

  /* General landscape form adjustments */
  .form-row {
    gap: 8px;
  }
  
  input, select, textarea {
    padding: 8px 10px;
    font-size: 14px;
    margin-bottom: 5px;
  }
  
  label {
    font-size: 12px;
    margin-top: 5px;
    margin-bottom: 2px;
  }
  
  button, button[type="submit"] {
    padding: 10px 15px;
    margin-top: 10px;
    margin-bottom: 20px; /* Add bottom margin */
  }
}