/* ========== Authentication Styles ========== */

/* Prevent scrolling when auth overlay is shown */
body.auth-active {
  overflow: hidden;
  height: 100vh;
}

/* ========== Login Overlay ========== */
.auth-overlay{
  position:fixed;
  top:0; left:0; right:0; bottom:0;
  background-image: url('../assets/background.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display:none;
  align-items:center;
  justify-content:center;
  z-index:1000;
  opacity:0;
  transition:opacity 0.4s var(--ease);
}

.auth-overlay::before{
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(40, 112, 47, 0.85) 0%, rgba(40, 112, 47, 0.75) 50%, rgba(34, 181, 97, 0.7) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0px, transparent 1px, transparent 40px, rgba(255, 255, 255, 0.02) 41px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0px, transparent 1px, transparent 40px, rgba(255, 255, 255, 0.02) 41px);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
}

@keyframes gradientShift{
  0%{ background-position:0% 50%; }
  50%{ background-position:100% 50%; }
  100%{ background-position:0% 50%; }
}

.auth-overlay.show{
  opacity:1;
}

/* ========== Login Container ========== */
.auth-container{
  max-width: 420px;
  width: 100%;
  padding: 20px;
  animation: slideUp 0.5s var(--ease);
  position: relative;
  z-index: 1;
}

.auth-box{
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 48px 40px;
  box-shadow:
    0 40px 80px rgba(0, 0, 0, 0.35),
    0 20px 40px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
  position: relative;
  overflow: hidden;
}

.auth-box::before{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg,
    var(--primary-600),
    var(--primary-500),
    var(--primary-400),
    var(--primary-500),
    var(--primary-600));
  background-size: 200% 100%;
  animation: shimmer 4s ease-in-out infinite;
}

.auth-box::after{
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background:
    radial-gradient(circle at 10% 20%, rgba(151, 180, 94, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(34, 181, 97, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

@keyframes slideUp{
  from{
    opacity:0;
    transform:translateY(20px);
  }
  to{
    opacity:1;
    transform:translateY(0);
  }
}

/* ========== Brand Section ========== */
.auth-brand{
  text-align:center;
  margin-bottom:24px;
  animation:fadeInDown 0.5s var(--ease);
  position: relative;
  z-index: 1;
}

.auth-icon{
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-600);
  background: linear-gradient(135deg, rgba(34, 181, 97, 0.08), rgba(40, 112, 47, 0.06));
  border-radius: 16px;
  animation: float 3s ease-in-out infinite;
}

.auth-icon svg{
  width: 28px;
  height: 28px;
  stroke-width: 2;
}

.auth-brand h1{
  font-size: 28px;
  font-weight: 700;
  color: #0F131C;
  margin: 0 0 6px 0;
  letter-spacing: -0.6px;
  line-height: 1.2;
}

.auth-subtitle{
  font-size: 13px;
  color: #64748B;
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.1px;
}

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

@keyframes float{
  0%, 100%{ transform:translateY(0px); }
  50%{ transform:translateY(-6px); }
}

/* ========== Login Card ========== */
.auth-card{
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.25),
    0 8px 16px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.4) inset;
  padding: 32px 28px 28px;
  text-align: center;
  animation: scaleIn 0.5s var(--ease) 0.2s backwards;
  position: relative;
  overflow: hidden;
  z-index: 1;
  max-width: 380px;
  margin: 0 auto;
}

/* Top accent line */
.auth-card::before{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--primary-600),
    var(--primary-500),
    var(--primary-600));
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}

.auth-card p{
  font-size: 14px;
  color: #64748B;
  margin: 0 0 24px 0;
  line-height: 1.5;
  position: relative;
  z-index: 1;
  font-weight: 400;
}

@keyframes shimmer{
  0%, 100%{ background-position: 0% 0%; }
  50%{ background-position: 100% 0%; }
}

@keyframes scaleIn{
  from{
    opacity: 0;
    transform: scale(0.95);
  }
  to{
    opacity: 1;
    transform: scale(1);
  }
}

/* Google Sign-In Button Container */
#googleSignInButton{
  display:flex;
  justify-content:center;
  align-items:center;
  margin:0 auto;
  position:relative;
  z-index:1;
  transition:transform 0.2s var(--ease);
}

#googleSignInButton:hover{
  transform:translateY(-1px);
}

/* ========== Fallback Google Button ========== */
.google-fallback-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:12px 24px;
  background: #ffffff;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  font-family:'Noto Sans Thai', 'Roboto', sans-serif;
  font-size:14px;
  font-weight:600;
  color:#1F2937;
  cursor:pointer;
  transition:all 0.2s var(--ease);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position:relative;
  z-index:1;
  min-width:240px;
}

.google-fallback-button:hover{
  background: #FAFAFA;
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform:translateY(-2px);
}

.google-fallback-button:active{
  transform:translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.google-fallback-button img{
  width: 18px;
  height: 18px;
}

.google-fallback-button svg{
  flex-shrink:0;
}

/* ========== In-App Browser Message ========== */
.in-app-browser-message{
  position:relative;
  z-index:1;
  animation:scaleIn 0.3s var(--ease);
}

/* ========== Error Message ========== */
.auth-error{
  margin-top:28px;
  padding:18px 24px;
  background: rgba(255, 245, 247, 0.95);
  border: 2px solid rgba(201, 42, 68, 0.3);
  border-radius: 12px;
  color: #1a1a1a;
  font-size:14px;
  line-height:1.6;
  text-align:center;
  display:none;
  animation:shake 0.4s var(--ease);
  box-shadow: 0 4px 16px rgba(201, 42, 68, 0.15);
  position:relative;
  z-index:1;
  font-weight: 500;
}

.auth-error::before{
  content: '⚠️';
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
}

@keyframes shake{
  0%, 100%{ transform:translateX(0); }
  25%{ transform:translateX(-10px); }
  75%{ transform:translateX(10px); }
}

/* ========== Info Text ========== */
.auth-info{
  text-align:center;
  margin-top:28px;
}

.auth-info p{
  font-size:13px;
  color:#666666;
  margin:0;
  line-height:1.6;
  font-weight: 400;
}

.auth-info a{
  color: var(--primary-600);
  text-decoration:none;
  font-weight:600;
  transition:color 0.2s var(--ease);
}

.auth-info a:hover{
  color: var(--primary-700);
  text-decoration:underline;
}

/* ========== User Profile Bar ========== */
.user-profile-bar{
  position:absolute;
  top:20px;
  right:20px;
  z-index:50;
  display:none;
}

/* Profile Button (Avatar only) */
.user-profile-button{
  background:rgba(255,255,255,0.97);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border-radius:50%;
  box-shadow:var(--shadow-md);
  padding:4px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--line-soft);
  transition:all 0.3s var(--ease);
  cursor:pointer;
  user-select:none;
  width:44px;
  height:44px;
}

.user-profile-button:hover{
  box-shadow:var(--shadow-lg);
  transform:translateY(-1px);
}

.user-profile-button:active{
  transform:translateY(0);
}

/* ========== User Avatar ========== */
.user-avatar{
  width:36px;
  height:36px;
  border-radius:50%;
  object-fit:cover;
  border:2px solid var(--line);
  flex-shrink:0;
}

/* Avatar Fallback (Letter circle like Gmail) */
.user-avatar-fallback{
  width:36px;
  height:36px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:600;
  font-size:14px;
  color:#fff;
  flex-shrink:0;
  text-transform:uppercase;
  user-select:none;
}

/* Hide user name in profile button */
.user-name{
  display:none;
}

/* ========== Dropdown Menu ========== */
.user-dropdown{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  background:#fff;
  border-radius:12px;
  box-shadow:0 4px 16px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  border:1px solid rgba(0,0,0,0.06);
  min-width:220px;
  padding:6px;
  display:none;
  animation:dropdownSlide 0.15s var(--ease);
  z-index:100;
}

.user-dropdown.show{
  display:block;
}

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

/* Dropdown Header */
.dropdown-header{
  padding:10px 10px 8px 10px;
}

.dropdown-user-name{
  font-size:14px;
  font-weight:600;
  color:var(--ink-900);
  margin:0 0 2px 0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  line-height:1.3;
}

.dropdown-user-email{
  font-size:12px;
  color:var(--ink-500);
  margin:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  line-height:1.3;
}

/* Dropdown Divider */
.dropdown-divider{
  height:1px;
  background:var(--line-soft);
  margin:6px 4px;
}

/* Dropdown Menu Item */
.dropdown-menu-item{
  width:100%;
  padding:8px 10px;
  border:none;
  border-radius:8px;
  background:transparent;
  font-family:'Noto Sans Thai',sans-serif;
  text-align:left;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
  transition:all 0.15s var(--ease);
  position:relative;
}

.dropdown-menu-item svg{
  flex-shrink:0;
  color:var(--ink-600);
  transition:all 0.15s var(--ease);
}

.dropdown-menu-item:hover{
  background:var(--neutral-100);
}

.dropdown-menu-item:hover svg{
  color:var(--primary-600);
  transform:scale(1.05);
}

.dropdown-menu-item:active{
  background:var(--neutral-200);
  transform:scale(0.98);
}

.dropdown-menu-text{
  flex:1;
  min-width:0;
}

.dropdown-menu-label{
  font-size:13px;
  font-weight:600;
  color:var(--ink-900);
  margin:0 0 1px 0;
  line-height:1.3;
}

.dropdown-menu-desc{
  font-size:11px;
  color:var(--ink-500);
  line-height:1.2;
  margin:0;
}

.dropdown-menu-arrow{
  flex-shrink:0;
  color:var(--ink-400);
  transition:all 0.15s var(--ease);
}

.dropdown-menu-item:hover .dropdown-menu-arrow{
  color:var(--primary-600);
  transform:translateX(2px);
}

/* ========== Sign Out Button ========== */
.sign-out-btn{
  width:100%;
  padding:8px 10px;
  background:transparent;
  color:var(--red-600);
  border:none;
  border-radius:8px;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  transition:all 0.15s var(--ease);
  font-family:'Noto Sans Thai',sans-serif;
  text-align:left;
  display:flex;
  align-items:center;
  gap:10px;
}

.sign-out-btn svg{
  flex-shrink:0;
  color:var(--red-600);
  transition:all 0.15s var(--ease);
}

.sign-out-btn:hover{
  background:rgba(220,38,38,0.08);
  color:var(--red-700);
}

.sign-out-btn:hover svg{
  color:var(--red-700);
  transform:translateX(-2px);
}

.sign-out-btn:active{
  background:rgba(220,38,38,0.15);
  transform:scale(0.98);
}
}

/* ========== Responsive Design ========== */
@media (max-width: 768px){
  .auth-container{
    max-width:100%;
    padding:20px;
  }

  .auth-card{
    padding:32px 24px;
  }

  .auth-brand h1{
    font-size:28px;
  }

  .user-profile-bar{
    top:12px;
    right:12px;
  }

  .user-avatar,
  .user-avatar-fallback{
    width:32px;
    height:32px;
  }

  .user-profile-button{
    width:40px;
    height:40px;
  }

  .user-name{
    font-size:13px;
    max-width:120px;
  }

  .sign-out-btn{
    padding:5px 14px;
    font-size:12px;
  }
}

@media (max-width: 480px){
  .auth-card{
    padding:28px 20px;
  }

  .auth-brand h1{
    font-size:24px;
  }

  .auth-subtitle{
    font-size:14px;
  }

  .auth-card h2{
    font-size:20px;
  }

  .user-name{
    max-width:100px;
  }
}

/* ========== Print Styles ========== */
@media print{
  .auth-overlay,
  .user-profile-bar{
    display:none !important;
  }
}
