/* ===========================
   Authentication Modal Styles
   =========================== */

/* Modal overlay */
.auth-modal-overlay {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.8); /* しっかりした暗い背景 */
  backdrop-filter: blur(8px);
  overflow: hidden;
  /* Flexbox centering */
  display: none; /* 初期状態 */
  justify-content: center;
  align-items: center;
}

.auth-modal-overlay.show {
  display: flex !important;
}

/* Modal content */
.auth-modal-content {
  background-color: var(--bg-secondary) !important;
  opacity: 1 !important;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
  z-index: 10001;
}

/* Header Auth Container */
.header-auth-container {
  display: flex;
  align-items: center;
  z-index: 900;
  flex-shrink: 0; /* Shrinkしないように */
}

/* User Profile Toggle */
.user-profile-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
}

.user-profile-toggle:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: bold;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name-header {
  font-size: 14px;
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Header login button */
.header-auth-btn {
  padding: 8px 20px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(var(--accent-primary-rgb), 0.3);
}

.header-auth-btn:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--accent-primary-rgb), 0.4);
}

/* User Dropdown */
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  padding: 8px;
  display: none;
  flex-direction: column;
  animation: dropdownFade 0.2s ease-out;
}

.user-dropdown.show {
  display: flex;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-info strong {
  font-size: 14px;
  color: var(--text-primary);
}

.dropdown-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.dropdown-item {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

.dropdown-item svg {
  color: var(--text-muted);
}

.dropdown-item:hover svg {
  color: var(--accent-primary);
}

/* Close button */
#auth-modal-close {
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 28px;
  font-weight: bold;
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 1;
  transition: color 0.2s;
}

#auth-modal-close:hover {
  color: var(--text-color);
}

/* Tabs */
.auth-tabs {
  display: flex;
  background: var(--bg-secondary);
  padding: 20px 20px 0;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.auth-tab:hover:not(.active) {
  color: var(--text-primary);
}

/* Forms */
.auth-form {
  display: none;
  padding: 30px;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  margin: 0 0 24px;
  color: var(--text-color);
  font-size: 24px;
  text-align: center;
}

/* Google button */
.auth-google-btn {
  width: 100%;
  padding: 12px;
  background: white;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
}

.auth-google-btn:hover {
  background: #f8f8f8;
  border-color: #ccc;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme='dark'] .auth-google-btn {
  background: #2a2a2a;
  color: #e0e0e0;
  border-color: #444;
}

[data-theme='dark'] .auth-google-btn:hover {
  background: #333;
  border-color: #555;
}

/* Divider */
.auth-divider {
  position: relative;
  text-align: center;
  margin: 24px 0;
}

.auth-divider::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background: var(--border-color);
}

.auth-divider span {
  position: relative;
  background: var(--bg-secondary);
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Form groups */
.auth-form .form-group {
  margin-bottom: 20px;
}

.auth-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-color);
  font-size: 14px;
  font-weight: 500;
}

.auth-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Error message */
.auth-error {
  display: none;
  padding: 10px;
  margin-bottom: 16px;
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 6px;
  color: #d32f2f;
  font-size: 14px;
}

/* Submit button */
.auth-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-submit-btn:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

/* Footer */
.auth-footer {
  margin-top: 20px;
  text-align: center;
}

.auth-footer a {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.auth-footer a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

/* Loading Overlay */
.auth-loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.auth-loader-overlay.show {
  display: flex;
  opacity: 1;
}

.loader-content {
  background: var(--bg-secondary);
  padding: 24px 40px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
}

.auth-loader-overlay .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(var(--accent-primary-rgb), 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Toast Notifications */
.auth-toast {
  position: fixed;
  bottom: 90px; /* Above tab nav */
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  z-index: 15000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  pointer-events: none;
}

.auth-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
}

.auth-toast.success .toast-content {
  color: var(--color-positive);
}

.auth-toast.error .toast-content {
  color: var(--color-negative);
}

.auth-toast.info .toast-content {
  color: var(--accent-primary);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .user-name-header {
    display: none; /* Icon only on small screens to save space */
  }

  /* mobile display adjustments for the auth container were here, but are no longer needed because the position is not absolute. */

  .auth-toast {
    width: 80%;
    text-align: center;
  }
}
