@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800&display=swap");

* {
  font-family: "Noto Sans Thai", sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #10b981 0%, #059669 25%, #34d399 50%, #6ee7b7 75%, #a7f3d0 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  position: relative;
  overflow: hidden;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Floating background shapes */
.background-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.floating-shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  animation: float 20s infinite ease-in-out;
}

.shape-1 {
  width: 300px;
  height: 300px;
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.shape-2 {
  width: 200px;
  height: 200px;
  top: 60%;
  right: 15%;
  animation-delay: 5s;
}

.shape-3 {
  width: 250px;
  height: 250px;
  bottom: 10%;
  left: 50%;
  animation-delay: 10s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(30px, -30px) rotate(120deg);
  }
  66% {
    transform: translate(-20px, 20px) rotate(240deg);
  }
}

#login {
  width: 100%;
  max-width: 480px;
  padding: 20px;
  position: relative;
  z-index: 1;
}

#login .container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

#login-box {
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(30px);
  box-shadow: 
    0 25px 80px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  padding: 3.5rem 2.5rem;
  border-radius: 28px;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
}

#login-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #10b981, #059669, #34d399, #6ee7b7, #a7f3d0);
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo-container {
  text-align: center;
  margin-bottom: 2.5rem;
  position: relative;
}

.logo-text {
  margin-top: 1.5rem;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.75rem 0;
  background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.logo-subtitle {
  font-size: 1.1rem;
  font-weight: 500;
  color: #4b5563;
  margin: 0;
  letter-spacing: 0.3px;
  line-height: 1.5;
  opacity: 0.9;
}

#login-box img:not(.cmu-logo) {
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.15));
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#login-box img:not(.cmu-logo):hover {
  transform: scale(1.08) translateY(-5px);
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.2));
}

#login-form .form-group {
  margin-bottom: 0.75rem;
}

#login-form .text-info {
  color: #1f2937 !important;
  font-weight: 700;
  font-size: 1.875rem;
  margin-bottom: 1rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  letter-spacing: -0.5px;
}

#login-form .text-info i {
  font-size: 1.5rem;
  color: #10b981;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.input-wrapper {
  position: relative;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 1.25rem;
  transition: all 0.3s ease;
  z-index: 1;
  pointer-events: none;
}

.input-wrapper.focused .input-icon {
  color: #10b981;
  transform: translateY(-50%) scale(1.1);
}

#login-form input[type="text"],
#login-form input[type="password"] {
  height: 56px;
  border: 2px solid #e5e7eb;
  padding: 0.75rem 1.25rem 0.75rem 3.5rem;
  border-radius: 14px;
  width: 100%;
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: #ffffff;
  color: #1f2937;
  font-weight: 500;
}

#login-form input[type="text"]::placeholder,
#login-form input[type="password"]::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

#login-form input[type="text"]:focus,
#login-form input[type="password"]:focus {
  border-color: #10b981;
  box-shadow: 
    0 0 0 4px rgba(16, 185, 129, 0.1),
    0 4px 12px rgba(16, 185, 129, 0.15);
  outline: none;
  transform: translateY(-1px);
}

#login-form input[type="text"]:hover:not(:focus),
#login-form input[type="password"]:hover:not(:focus) {
  border-color: #d1d5db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.password-toggle {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: all 0.3s ease;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: #10b981;
  transform: translateY(-50%) scale(1.1);
}

.password-toggle:active {
  transform: translateY(-50%) scale(0.95);
}

#login-form input[type="submit"] {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 8px 20px rgba(16, 185, 129, 0.4),
    0 0 0 0 rgba(16, 185, 129, 0.4);
  margin-top: 0.5rem;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
  height: auto;
  min-height: 56px;
  box-sizing: border-box;
}

#login-form input[type="submit"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

#login-form input[type="submit"]:hover::before {
  left: 100%;
}

#login-form input[type="submit"]:hover {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  transform: translateY(-3px);
  box-shadow: 
    0 12px 28px rgba(16, 185, 129, 0.5),
    0 0 0 4px rgba(16, 185, 129, 0.1);
}

#login-form input[type="submit"]:active {
  transform: translateY(-1px);
  box-shadow: 
    0 6px 16px rgba(16, 185, 129, 0.4),
    0 0 0 2px rgba(16, 185, 129, 0.2);
}

.text-center {
  text-align: center;
}

.text-white {
  color: #fff !important;
}

.form-group {
  position: relative;
}

.form-group i {
  color: #10b981;
  margin-right: 0.5rem;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 2rem 0 0.5rem 0;
  position: relative;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e5e7eb;
}

.divider span {
  padding: 0 1rem;
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.98);
  position: relative;
}

/* CMU Account Button */
.btn-cmu {
  width: 100%;
  background: #ffffff;
  color: #1f2937;
  border: 2px solid #8b5cf6;
  border-radius: 14px;
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
  margin-top: 0;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  height: auto;
  min-height: 56px;
  white-space: nowrap;
}

.btn-cmu span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-cmu i {
  font-size: 1.25rem;
  color: #8b5cf6;
  transition: all 0.3s ease;
}

.btn-cmu .cmu-logo,
.cmu-logo {
  height: 16px !important;
  width: auto;
  object-fit: contain;
  transition: all 0.3s ease;
  display: block;
  flex-shrink: 0;
  max-height: 16px;
}

.btn-cmu::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.1), transparent);
  transition: left 0.5s ease;
}

.btn-cmu:hover::before {
  left: 100%;
}

.btn-cmu:hover {
  background: #f5f3ff;
  border-color: #7c3aed;
  transform: translateY(-2px);
  box-shadow: 
    0 8px 20px rgba(139, 92, 246, 0.25),
    0 0 0 4px rgba(139, 92, 246, 0.1);
}

.btn-cmu:hover i {
  transform: scale(1.1);
  color: #7c3aed;
}

.btn-cmu:hover .cmu-logo {
  transform: scale(1.05);
  max-height: inherit;
}

.btn-cmu:active {
  transform: translateY(0);
  box-shadow: 
    0 4px 12px rgba(139, 92, 246, 0.2),
    0 0 0 2px rgba(139, 92, 246, 0.15);
}

/* Pharmacy MIS Link */
.pharmacy-link-container {
  text-align: center;
  margin-top: 0;
  padding-top: 0;
}

.pharmacy-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #10b981;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  position: relative;
}

.pharmacy-link i {
  font-size: 1.125rem;
  transition: all 0.3s ease;
}

.pharmacy-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: #10b981;
  transition: width 0.3s ease;
}

.pharmacy-link:hover {
  color: #059669;
  background: rgba(16, 185, 129, 0.05);
}

.pharmacy-link:hover i {
  transform: scale(1.1);
  color: #059669;
}

.pharmacy-link:hover::after {
  width: calc(100% - 2rem);
}

.pharmacy-link:active {
  transform: scale(0.98);
}

@media only screen and (max-width: 768px) {
  body {
    padding: 10px;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding-top: 20px;
    padding-bottom: 20px;
  }

  #login {
    max-width: 100%;
    padding: 10px;
    width: 100%;
  }

  #login .container {
    height: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #login-box {
    max-width: 100%;
    padding: 2rem 1.5rem;
    border-radius: 20px;
    margin: 0 auto;
  }

  .logo-container {
    margin-bottom: 1.5rem;
  }

  #login-box img:not(.cmu-logo) {
    height: 90px;
    max-width: 100%;
  }
  
  #login-box .cmu-logo {
    height: 13px !important;
    max-height: 13px !important;
    max-width: none;
  }

  .logo-text {
    margin-top: 1rem;
  }

  #login-form .text-info {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
  }

  .logo-title {
    font-size: 1.3rem;
    line-height: 1.4;
  }

  .logo-subtitle {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  #login-form input[type="text"],
  #login-form input[type="password"] {
    height: 50px;
    font-size: 0.95rem;
    padding-left: 3rem;
    padding-right: 3rem;
  }

  .input-icon {
    left: 0.875rem;
    font-size: 1.1rem;
  }

  .password-toggle {
    right: 0.875rem;
    font-size: 1.1rem;
  }

  #login-form input[type="submit"] {
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    min-height: 50px;
  }

  .btn-cmu {
    padding: 0.875rem 0.75rem;
    font-size: 0.85rem;
    min-height: 50px;
    white-space: nowrap;
    gap: 0.5rem;
  }

  .btn-cmu span {
    white-space: nowrap;
    text-align: center;
    flex-shrink: 1;
  }

  .btn-cmu .cmu-logo,
  .cmu-logo {
    height: 13px !important;
    max-height: 13px !important;
    flex-shrink: 0;
  }

  .divider {
    margin: 1.25rem 0 0.5rem 0;
  }

  .divider span {
    font-size: 0.8rem;
    padding: 0 0.75rem;
  }

  .pharmacy-link-container {
    margin-top: 0;
    padding-top: 0;
  }

  .pharmacy-link {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    white-space: normal;
    text-align: center;
    justify-content: center;
  }

  .shape-1, .shape-2, .shape-3 {
    opacity: 0.3;
    display: none;
  }
}

@media only screen and (max-width: 480px) {
  body {
    padding: 15px 5px;
    align-items: center;
    justify-content: center;
  }

  #login {
    padding: 5px;
  }

  #login-box {
    padding: 1.5rem 1.25rem;
    border-radius: 18px;
  }

  .logo-container {
    margin-bottom: 1.25rem;
  }

  #login-box img:not(.cmu-logo) {
    height: 80px;
  }
  
  #login-box .cmu-logo {
    height: 11px !important;
    max-height: 11px !important;
  }

  .logo-text {
    margin-top: 0.75rem;
  }

  #login-form .text-info {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
  }

  #login-form .text-info i {
    font-size: 1.2rem;
  }

  .logo-title {
    font-size: 1.15rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
  }

  .logo-subtitle {
    font-size: 0.85rem;
    line-height: 1.3;
  }

  #login-form input[type="text"],
  #login-form input[type="password"] {
    height: 48px;
    font-size: 0.9rem;
    padding-left: 2.75rem;
    padding-right: 2.75rem;
  }

  .input-icon {
    left: 0.75rem;
    font-size: 1rem;
  }

  .password-toggle {
    right: 0.75rem;
    font-size: 1rem;
  }

  #login-form input[type="submit"] {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    min-height: 48px;
  }

  .btn-cmu {
    padding: 0.75rem 0.625rem;
    font-size: 0.8rem;
    min-height: 48px;
    gap: 0.4rem;
    white-space: nowrap;
  }

  .btn-cmu span {
    white-space: nowrap;
    flex-shrink: 1;
  }

  .btn-cmu .cmu-logo,
  .cmu-logo {
    height: 11px !important;
    max-height: 11px !important;
    flex-shrink: 0;
  }

  .divider {
    margin: 1rem 0 0.5rem 0;
  }

  .divider span {
    font-size: 0.75rem;
    padding: 0 0.5rem;
  }

  .pharmacy-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.625rem;
  }

  .pharmacy-link i {
    font-size: 1rem;
  }
}

@media only screen and (max-width: 360px) {
  #login-box {
    padding: 1.25rem 1rem;
  }

  #login-box img:not(.cmu-logo) {
    height: 70px;
  }
  
  #login-box .cmu-logo {
    height: 9px !important;
    max-height: 9px !important;
  }

  .logo-title {
    font-size: 1rem;
  }

  .logo-subtitle {
    font-size: 0.8rem;
  }

  #login-form .text-info {
    font-size: 1.1rem;
  }

  .btn-cmu {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
    gap: 0.35rem;
  }

  .btn-cmu span {
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .btn-cmu .cmu-logo,
  .cmu-logo {
    height: 9px !important;
    max-height: 9px !important;
  }
}
