* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #fdfeff;
}

/* Header matching index.html */
header {
  background: linear-gradient(90deg, #2c3e50, #34495e);
  color: #ffffff;
  padding: 40px 20px;
  text-align: center;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 1px 1px 2px #000;
}

header p {
  font-size: 1.1rem;
  text-shadow: 1px 1px 1px #000;
  margin: 0;
}

/* Main container */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
  padding: 40px 20px;
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 450px;
  animation: fadeIn 0.5s ease;
}

.login-container h2 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 1.8rem;
  font-weight: 600;
}

.login-container .subtitle {
  text-align: center;
  color: #666;
  margin-bottom: 30px;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Form styling */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
  font-size: 0.95rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  transition: border-color 0.3s, box-shadow 0.3s;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: white;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: #2c3e50;
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

/* Password wrapper with toggle button */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 50px;
}

.toggle-password {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 48px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: color 0.3s ease, background-color 0.3s ease;
  border-radius: 0 5px 5px 0;
  margin: 0;
}

.toggle-password:hover {
  color: #2c3e50;
  background-color: rgba(44, 62, 80, 0.05);
}

.toggle-password:focus {
  outline: 2px solid #2c3e50;
  outline-offset: -2px;
}

.toggle-password:active {
  background-color: rgba(44, 62, 80, 0.1);
}

.toggle-password svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* Buttons */
button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-top: 10px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.login-btn {
  background-color: #2c3e50;
  color: white;
}

.login-btn:hover {
  background-color: #34495e;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(44, 62, 80, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

.register-btn {
  background-color: #27ae60;
  color: white;
}

.register-btn:hover {
  background-color: #229954;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.register-btn:active {
  transform: translateY(0);
}

/* Message styling */
#message {
  padding: 12px;
  margin: 15px 0;
  border-radius: 5px;
  text-align: center;
  font-weight: 500;
  display: none;
  animation: slideIn 0.3s ease;
}

#message.error {
  background-color: #fee;
  color: #c00;
  border: 1px solid #fcc;
  display: block;
}

#message.success {
  background-color: #efe;
  color: #0a0;
  border: 1px solid #cfc;
  display: block;
}

/* Divider */
.divider {
  text-align: center;
  margin: 25px 0;
  position: relative;
  color: #999;
  font-size: 0.9rem;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 45%;
  height: 1px;
  background-color: #ddd;
}

.divider::before {
  left: 0;
}

.divider::after {
  right: 0;
}

/* Footer */
.footer {
  background-color: #2c3e50;
  color: white;
  text-align: center;
  padding: 15px 10px;
  font-size: 0.85em;
  margin-top: auto;
}

.footer p {
  margin: 5px 0;
}

.footer strong {
  font-weight: 600;
}

/* Back to home link */
.back-home {
  text-align: center;
  margin-top: 20px;
}

.back-home a {
  color: #2c3e50;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.3s;
  display: inline-block;
  padding: 5px;
}

.back-home a:hover {
  color: #34495e;
  text-decoration: underline;
}

/* Loading state */
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== TABLET RESPONSIVE (768px - 1024px) ========== */
@media (max-width: 1024px) and (min-width: 769px) {
  header {
    padding: 35px 20px;
  }

  header h1 {
    font-size: 2.2rem;
  }

  header p {
    font-size: 1.05rem;
  }

  .login-wrapper {
    padding: 35px 25px;
    min-height: calc(100vh - 190px);
  }

  .login-container {
    padding: 38px;
    max-width: 500px;
  }

  .login-container h2 {
    font-size: 1.7rem;
  }

  input[type="email"],
  input[type="password"],
  input[type="text"] {
    padding: 13px 14px;
    font-size: 16px;
  }

  .password-wrapper input {
    padding-right: 50px;
  }

  button {
    padding: 13px;
    font-size: 16px;
  }

  .toggle-password {
    width: 48px;
  }
}

/* ========== MOBILE RESPONSIVE (481px - 768px) ========== */
@media (max-width: 768px) {
  header {
    padding: 30px 20px;
  }

  header h1 {
    font-size: 2rem;
  }

  header p {
    font-size: 1rem;
  }

  .login-wrapper {
    padding: 25px 20px;
    min-height: calc(100vh - 170px);
  }

  .login-container {
    padding: 32px 28px;
    max-width: 450px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  }

  .login-container h2 {
    font-size: 1.6rem;
    margin-bottom: 8px;
  }

  .login-container .subtitle {
    font-size: 0.92rem;
    margin-bottom: 25px;
  }

  .form-group {
    margin-bottom: 18px;
  }

  .form-group label {
    font-size: 0.93rem;
    margin-bottom: 7px;
  }

  input[type="email"],
  input[type="password"],
  input[type="text"] {
    padding: 13px;
    font-size: 16px;
  }

  .password-wrapper input {
    padding-right: 48px;
  }

  button {
    padding: 13px;
    font-size: 15px;
  }

  .toggle-password {
    width: 46px;
  }

  .toggle-password svg {
    width: 19px;
    height: 19px;
  }

  .divider {
    margin: 22px 0;
    font-size: 0.88rem;
  }

  .back-home a {
    font-size: 0.93rem;
  }

  .footer {
    font-size: 0.8rem;
    padding: 12px 10px;
  }
}

/* ========== SMALL MOBILE (320px - 480px) ========== */
@media (max-width: 480px) {
  header {
    padding: 25px 15px;
  }

  header h1 {
    font-size: 1.7rem;
    margin-bottom: 8px;
  }

  header p {
    font-size: 0.95rem;
  }

  .login-wrapper {
    padding: 20px 15px;
    min-height: calc(100vh - 150px);
  }

  .login-container {
    padding: 28px 24px;
    border-radius: 8px;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.08);
  }

  .login-container h2 {
    font-size: 1.5rem;
    margin-bottom: 6px;
  }

  .login-container .subtitle {
    font-size: 0.9rem;
    margin-bottom: 22px;
  }

  .form-group {
    margin-bottom: 16px;
  }

  .form-group label {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }

  input[type="email"],
  input[type="password"],
  input[type="text"] {
    padding: 12px;
    font-size: 16px; /* Keep 16px to prevent zoom on iOS */
  }

  .password-wrapper input {
    padding-right: 46px;
  }

  button {
    padding: 12px;
    font-size: 15px;
    margin-top: 8px;
  }

  .toggle-password {
    width: 44px;
  }

  .toggle-password svg {
    width: 18px;
    height: 18px;
  }

  #message {
    padding: 11px;
    margin: 12px 0;
    font-size: 0.9rem;
  }

  .divider {
    margin: 20px 0;
    font-size: 0.85rem;
  }

  .back-home {
    margin-top: 18px;
  }

  .back-home a {
    font-size: 0.9rem;
  }

  .footer {
    font-size: 0.75rem;
    padding: 10px 8px;
  }
}

/* ========== EXTRA SMALL MOBILE (< 360px) ========== */
@media (max-width: 360px) {
  header h1 {
    font-size: 1.5rem;
  }

  header p {
    font-size: 0.88rem;
  }

  .login-container {
    padding: 24px 20px;
  }

  .login-container h2 {
    font-size: 1.4rem;
  }

  .login-container .subtitle {
    font-size: 0.88rem;
  }

  input[type="email"],
  input[type="password"],
  input[type="text"] {
    padding: 11px;
  }

  button {
    padding: 11px;
    font-size: 14px;
  }

  .toggle-password {
    width: 42px;
  }
}

/* Accessibility improvements */
*:focus-visible {
  outline: 2px solid #2c3e50;
  outline-offset: 2px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Touch-friendly tap highlights */
a, button, input, .toggle-password {
  -webkit-tap-highlight-color: transparent;
}

/* Ensure proper touch targets on mobile (44x44px minimum) */
@media (max-width: 768px) {
  button,
  .toggle-password,
  .back-home a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .toggle-password {
    min-width: 44px;
  }
}

/* Prevent zoom on input focus for iOS */
@media (max-width: 768px) {
  input[type="email"],
  input[type="password"],
  input[type="text"] {
    font-size: 16px !important;
  }
}

/* Improve touch responsiveness */
@media (hover: none) and (pointer: coarse) {
  button:active {
    transform: scale(0.98);
  }

  .toggle-password:active {
    background-color: rgba(44, 62, 80, 0.15);
  }
}