/* =============================================
   Admin Panel - Hamonic Event
   Theme: Dark Professional
   ============================================= */

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

:root {
  --admin-bg: #0f1117;
  --admin-surface: #1a1d27;
  --admin-surface-2: #232735;
  --admin-surface-3: #2d3142;
  --admin-border: rgba(255,255,255,.08);
  --admin-border-hover: rgba(255,255,255,.15);
  --admin-text: #e4e7ef;
  --admin-text-muted: #8b90a0;
  --admin-text-dim: #5c6070;
  --accent: #4fd18b; /* Hamonic Emerald Mint */
  --accent-hover: #3ab776; /* Hamonic Active Forest */
  --accent-glow: rgba(79, 209, 139, 0.15);
  --accent-glow-strong: rgba(79, 209, 139, 0.25);
  --red-500: #ef4444;
  --red-glow: rgba(239,68,68,.15);
  --amber-500: #f59e0b;
  --font: 'Kanit', 'Noto Sans Thai', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
}

/* --- Reset --- */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }

body.admin-body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--admin-text);
  background: var(--admin-bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Animated Background */
.login-bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background:
    radial-gradient(ellipse 600px 600px at 20% 50%, rgba(34,197,94,.08) 0%, transparent 50%),
    radial-gradient(ellipse 500px 500px at 80% 20%, rgba(34,197,94,.05) 0%, transparent 50%),
    radial-gradient(ellipse 400px 400px at 60% 80%, rgba(34,197,94,.04) 0%, transparent 50%);
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-30px, -20px) rotate(2deg); }
}

/* Grid pattern overlay */
.login-bg::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* Floating orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .5;
  animation: orbFloat 18s ease-in-out infinite;
}
.orb-1 {
  width: 300px; height: 300px;
  background: rgba(34,197,94,.08);
  top: 10%; left: 15%;
  animation-duration: 22s;
}
.orb-2 {
  width: 200px; height: 200px;
  background: rgba(34,197,94,.06);
  bottom: 20%; right: 10%;
  animation-duration: 18s;
  animation-delay: -5s;
}
.orb-3 {
  width: 150px; height: 150px;
  background: rgba(34,197,94,.05);
  top: 60%; left: 60%;
  animation-duration: 25s;
  animation-delay: -10s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.1); }
  50% { transform: translate(-20px, 30px) scale(0.95); }
  75% { transform: translate(15px, 15px) scale(1.05); }
}

/* Login Container */
.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  animation: loginSlideIn .6s ease both;
}

@keyframes loginSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Login Card */
.login-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-2xl);
  padding: 40px 32px;
  backdrop-filter: blur(20px);
  box-shadow:
    0 4px 24px rgba(0,0,0,.3),
    0 0 80px rgba(34,197,94,.03);
  transition: border-color .3s, box-shadow .3s;
}

.login-card:hover {
  border-color: var(--admin-border-hover);
  box-shadow:
    0 8px 40px rgba(0,0,0,.4),
    0 0 100px rgba(34,197,94,.05);
}

/* Login Header */
.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Glow effect behind logo */
.login-logo::before {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(34,197,94,.12) 0%, transparent 70%);
  border-radius: 50%;
  animation: logoPulse 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes logoPulse {
  0%, 100% { opacity: .6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.login-logo img {
  height: 48px;
  width: auto;
  position: relative;
  z-index: 1;
  filter: brightness(0) invert(1) drop-shadow(0 2px 8px rgba(34,197,94,.25));
  transition: transform .3s ease, filter .3s ease;
}

.login-logo:hover img {
  transform: scale(1.05);
}

/* Fallback emoji icon when logo fails to load */
.login-logo .logo-fallback {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent) 0%, #15803d 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 4px 20px rgba(34,197,94,.3);
  position: relative;
  z-index: 1;
}

/* Accent line under logo */
.login-logo-accent {
  display: block;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
  margin: 0 auto 16px;
  opacity: .5;
}

.login-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--admin-text);
  margin-bottom: 6px;
}

.login-header p {
  font-size: .85rem;
  color: var(--admin-text-muted);
}

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

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--admin-text-muted);
  margin-bottom: 8px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

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

.input-icon {
  position: absolute;
  left: 14px;
  font-size: 1rem;
  color: var(--admin-text-dim);
  pointer-events: none;
  transition: color .3s;
  z-index: 1;
}

.form-input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  font-family: var(--font);
  font-size: .925rem;
  color: var(--admin-text);
  background: var(--admin-surface-2);
  border: 1.5px solid var(--admin-border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all .25s ease;
}

.form-input::placeholder {
  color: var(--admin-text-dim);
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--admin-surface-3);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input:focus ~ .input-icon,
.form-input:focus + .input-icon {
  color: var(--accent);
}

/* Password toggle */
.password-toggle {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--admin-text-dim);
  padding: 4px;
  transition: color .2s;
  z-index: 1;
}
.password-toggle:hover {
  color: var(--admin-text-muted);
}

/* Error States */
.form-input.error {
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.form-error {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: .8rem;
  color: var(--red-500);
}
.form-error.visible {
  display: flex;
}

/* Alert Box */
.alert-box {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: .85rem;
  margin-bottom: 20px;
  animation: alertSlide .3s ease both;
}

.alert-box.visible {
  display: flex;
}

.alert-box.alert-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.2);
  color: #fca5a5;
}

.alert-box.alert-success {
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.2);
  color: #86efac;
}

.alert-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

/* Login Button */
.login-btn {
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #15803d 100%);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all .3s ease;
  position: relative;
  overflow: hidden;
  margin-top: 4px;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(34,197,94,.35);
}

.login-btn:active:not(:disabled) {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Ripple effect */
.login-btn::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width .5s ease, height .5s ease;
}
.login-btn:active::after {
  width: 400px; height: 400px;
}

/* Loading state */
.login-btn .btn-text { transition: opacity .2s; }
.login-btn .btn-loader {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .2s;
}

.login-btn.loading .btn-text { opacity: 0; }
.login-btn.loading .btn-loader { opacity: 1; }

/* Spinner */
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* Login Footer */
.login-footer {
  margin-top: 28px;
  text-align: center;
}

.login-footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--admin-text-muted);
  text-decoration: none;
  transition: color .2s;
}
.login-footer a:hover {
  color: var(--accent);
}

/* Remember me checkbox */
.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

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

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 18px; height: 18px;
  border: 1.5px solid var(--admin-border-hover);
  border-radius: 4px;
  background: var(--admin-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}

.checkbox-custom::after {
  content: '✓';
  font-size: .7rem;
  color: #fff;
  opacity: 0;
  transform: scale(0);
  transition: all .2s;
}

.checkbox-label input:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked + .checkbox-custom::after {
  opacity: 1;
  transform: scale(1);
}

/* Divider */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--admin-text-dim);
  font-size: .75rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--admin-border);
}

/* Version badge */
.version-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--admin-surface-2);
  border: 1px solid var(--admin-border);
  border-radius: 20px;
  font-size: .7rem;
  color: var(--admin-text-dim);
  margin-top: 16px;
}

/* Security info */
.security-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  font-size: .75rem;
  color: var(--admin-text-dim);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 480px) {
  .login-card {
    padding: 32px 24px;
    border-radius: var(--radius-xl);
  }

  .login-header h1 {
    font-size: 1.25rem;
  }

  .form-input {
    padding: 12px 12px 12px 40px;
    font-size: .875rem;
  }

  .login-btn {
    padding: 12px 20px;
    font-size: .925rem;
  }
}

/* Focus visible for keyboard nav */
.form-input:focus-visible,
.login-btn:focus-visible,
.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
