@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #013D84;
  --primary-hover: #084c9c;
  --primary-light: rgba(1, 61, 132, 0.08);
  --accent-color: #c5a48e;
  --accent-hover: #b4917a;
  --bg-color: #F9F7F5;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text-main: #0c1b40;
  --text-muted: #64748b;
  --success-color: #10b981;
  --success-bg: #ecfdf5;
  --error-color: #ef4444;
  --error-bg: #fef2f2;
  --border-color: #e2e8f0;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-main: 0 10px 30px -5px rgba(12, 27, 64, 0.08), 0 4px 12px -2px rgba(12, 27, 64, 0.03);
  --shadow-input: 0 2px 4px rgba(12, 27, 64, 0.02);
}

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

body {
  font-family: 'Outfit', 'Kanit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Decorative Background Blobs */
body::before, body::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.5;
  pointer-events: none;
}

body::before {
  top: -100px;
  right: -100px;
  background: radial-gradient(circle, var(--accent-color) 0%, transparent 70%);
}

body::after {
  bottom: -100px;
  left: -100px;
  background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
}

/* Auth Container */
.auth-container {
  width: 100%;
  max-width: 480px;
  padding: 20px;
  animation: fadeIn 0.6s ease-out;
}

/* Logo and Header Styling */
.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo-link {
  display: inline-block;
  margin-bottom: 12px;
}

.logo-img {
  height: 70px;
  width: auto;
  object-fit: contain;
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.925rem;
}

/* Auth Card */
.auth-card {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-main);
  padding: 32px;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-input);
  outline: none;
  transition: var(--transition-smooth);
}

/* Password Input adjustment for toggle button */
.input-wrapper .form-input[type="password"],
.input-wrapper .form-input[type="text"] {
  padding-right: 48px;
}

.form-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* Password Toggle Icon */
.toggle-password {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.toggle-password:hover {
  color: var(--primary-color);
}

.toggle-password svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Select Style */
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  padding-right: 40px;
}

/* Validation Feedback based on modern-web-guidance */
.error-msg {
  display: none;
  color: var(--error-color);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 5px;
}

/* Show error styles only after user interaction */
.form-input:user-invalid {
  border-color: var(--error-color);
  background-color: var(--error-bg);
}

.form-group:has(.form-input:user-invalid) .error-msg,
.form-group:has(.form-input.user-invalid-fallback) .error-msg {
  display: block;
}

.form-input:user-valid {
  border-color: var(--success-color);
}

/* Password rules list - fits above password */
.rules-list {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rules-list li {
  transition: var(--transition-smooth);
}

.form-group:has(.form-input:user-invalid) .rules-list {
  color: var(--error-color);
}

.form-group:has(.form-input:user-valid) .rules-list {
  display: none;
}

/* Accent Color for Brand-Consistent Checkbox */
body {
  accent-color: var(--primary-color);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  gap: 8px;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Custom Fallback for older browsers without accent-color */
@supports not (accent-color: var(--primary-color)) {
  .checkbox-label input[type="checkbox"] {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }

  .checkbox-label {
    position: relative;
    padding-left: 24px;
  }

  .checkbox-label span::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-color);
    background: #ffffff;
    border-radius: 4px;
    box-sizing: border-box;
    transition: var(--transition-smooth);
  }

  .checkbox-label input[type="checkbox"]:focus-visible + span::before {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }

  .checkbox-label input[type="checkbox"]:checked + span::before {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
  }

  .checkbox-label input[type="checkbox"]:checked + span::after {
    content: "✓";
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-weight: bold;
    font-size: 0.75rem;
  }
}

/* Form Footer links */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.forgot-link, .switch-auth-link {
  color: var(--primary-color);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.forgot-link:hover, .switch-auth-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.switch-auth {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  width: 100%;
  padding: 13px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(1, 61, 132, 0.15);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(1, 61, 132, 0.25);
  transform: translateY(-1px);
}

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

/* Button Loading State */
.btn-loader {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.btn.loading .btn-text {
  visibility: hidden;
}

.btn.loading .btn-loader {
  display: block;
  position: absolute;
}

/* Alert Boxes */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
}

.alert-error {
  background-color: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error-color);
}

.alert-success {
  background-color: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success-color);
}

/* Dashboard Styling */
.dashboard-container {
  width: 100%;
  max-width: 600px;
  padding: 20px;
}

.dashboard-card {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-main);
  padding: 40px;
  text-align: center;
}
.user-avatar-container {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 20px;
  border: 2.5px solid var(--primary-color);
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(12, 27, 64, 0.08);
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dashboard-welcome h2 {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.dashboard-role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background-color: var(--accent-color);
  color: #ffffff;
  margin-bottom: 24px;
}

.user-info-list {
  background-color: var(--bg-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  margin-bottom: 30px;
}

.user-info-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.925rem;
}

.user-info-item:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.info-label {
  font-weight: 600;
  color: var(--text-muted);
}

.info-val {
  font-weight: 500;
  color: var(--text-main);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-color);
  border-color: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .auth-card {
    padding: 24px 20px;
  }
  
  .auth-header h1 {
    font-size: 1.5rem;
  }
}
