/* ══════════════════════════════════════════════
   BibiBook User Auth — login / profile setup
   ══════════════════════════════════════════════ */

/* ── Modal backdrop ─────────────────────────── */
#auth-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9500;
  align-items: center;
  justify-content: center;
}
#auth-modal.open { display: flex; }

#auth-box {
  background: #fff;
  border-radius: 6px;
  width: 360px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-family: 'Lucida Grande', Arial, sans-serif;
}

#auth-header {
  background: linear-gradient(to bottom, #3e5a94, #2d4373);
  padding: 16px 20px 12px;
  color: #fff;
}
#auth-header h2 {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: bold;
  font-family: Georgia, serif;
  letter-spacing: 0.03em;
}
#auth-header p {
  margin: 0;
  font-size: 11px;
  color: #c8d4f0;
}

#auth-body { padding: 18px 20px 20px; }

/* ── Choice screen ──────────────────────────── */
#auth-choice { display: flex; flex-direction: column; gap: 10px; }

.auth-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #c4cfe0;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.auth-option:hover { background: #f0f4fb; border-color: #3b5998; }

.auth-option-avatar {
  width: 40px; height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #2d5a9e;
}
.auth-option-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-option-avatar-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: #e9eaed;
  color: #666;
}

.auth-option-text strong {
  display: block;
  font-size: 12px;
  color: #1c2a3a;
  margin-bottom: 2px;
}
.auth-option-text span {
  font-size: 10px;
  color: #777;
}

/* ── Setup screen ───────────────────────────── */
#auth-setup { display: none; flex-direction: column; gap: 12px; }

.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: bold;
  color: #4a5568;
  margin-bottom: 4px;
}
.auth-field input[type="text"] {
  width: 100%;
  border: 1px solid #c4cfe0;
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.auth-field input[type="text"]:focus { border-color: #3b5998; }

/* Avatar picker */
#auth-avatar-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}
#auth-avatar-preview {
  width: 48px; height: 48px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid #c4cfe0;
  background: #e9eaed;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
#auth-avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

#auth-avatar-upload-btn {
  background: #f0f4fb;
  border: 1px solid #c4cfe0;
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  color: #3b5998;
}
#auth-avatar-upload-btn:hover { background: #e4eaf5; }
#auth-avatar-file { display: none; }

.auth-hint { font-size: 10px; color: #aaa; }

.auth-submit-btn {
  width: 100%;
  background: linear-gradient(to bottom, #5b74a8, #3b5998);
  color: #fff;
  border: 1px solid #2d4373;
  border-radius: 4px;
  padding: 8px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  margin-top: 4px;
}
.auth-submit-btn:hover { background: linear-gradient(to bottom, #6a84b8, #4a6aa8); }

.auth-back-link {
  font-size: 10px;
  color: #3b5998;
  text-align: center;
  cursor: pointer;
  margin-top: -4px;
}
.auth-back-link:hover { text-decoration: underline; }

/* ── User menu (top-right when logged in) ───── */
#user-menu-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.15s;
}
#user-menu-btn:hover { background: rgba(255,255,255,0.12); }
#user-menu-avatar {
  width: 22px; height: 22px;
  border-radius: 3px;
  overflow: hidden;
  background: #4a6fa5;
  flex-shrink: 0;
}
#user-menu-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#user-menu-name {
  font-size: 11px;
  color: #e8f0fe;
  font-weight: bold;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#user-menu-caret { color: #c8d4f0; font-size: 9px; }

#user-dropdown {
  display: none;
  position: absolute;
  top: 38px;
  right: 8px;
  background: #fff;
  border: 1px solid #c4cfe0;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 9000;
  min-width: 140px;
  overflow: hidden;
}
#user-dropdown.open { display: block; }
.user-dropdown-item {
  padding: 7px 12px;
  font-size: 11px;
  color: #333;
  cursor: pointer;
  font-family: 'Lucida Grande', Arial, sans-serif;
}
.user-dropdown-item:hover { background: #f0f4fb; }
.user-dropdown-item.danger { color: #c00; }
