/* Auth-related styles — LoginPage, ProfilePage, NavBar.
 * Kept in a separate file so main.css stays a learning baseline.
 */

/* ── Sidebar nav ──────────────────────────────────────────────── */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 0;
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: #f9fafb;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}

.sidebar-links {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.sidebar-link {
  display: block;
  color: #d1d5db;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.is-active {
  background: #2563eb;
  color: #fff;
}

/* User-menu trigger pinned to bottom-left. Opens a popover with logout +
 * profile-info shortcut when the user is authenticated. */
.sidebar-user {
  position: relative;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: #f9fafb;
  font: inherit;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-user-trigger:hover,
.sidebar-user.is-open .sidebar-user-trigger {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.sidebar-user-name {
  flex: 1 1 auto;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.sidebar-user-caret {
  color: #9ca3af;
  font-size: 12px;
}

/* Popover that appears above the trigger when the menu is open. */
.sidebar-user-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% - 4px);
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.3);
  padding: 6px;
  display: none;
}

.sidebar-user.is-open .sidebar-user-menu {
  display: block;
}

.sidebar-user-menu button,
.sidebar-user-menu a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-decoration: none;
  border-radius: 4px;
  cursor: pointer;
}

.sidebar-user-menu button:hover,
.sidebar-user-menu a:hover {
  background: #f3f4f6;
}

.sidebar-user-menu button.is-danger {
  color: #b91c1c;
}

.sidebar-user-menu button.is-danger:hover {
  background: #fef2f2;
}

.sidebar-user-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-user-actions a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
}

.sidebar-user-actions .auth-login {
  background: #2563eb;
  color: #fff;
}

.sidebar-user-actions .auth-register {
  background: rgba(255, 255, 255, 0.08);
  color: #f9fafb;
}

/* ── Profile edit form ─────────────────────────────────────────── */

.profile-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 0 20px;
}

.profile-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-edit-field label {
  font-size: 13px;
  color: #6b7280;
}

.profile-edit-field input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
  background: #fff;
}

.profile-edit-field input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.profile-edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.profile-edit-actions .btn-primary,
.profile-edit-actions .btn-secondary {
  flex: 1 1 0;
  padding: 10px 16px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
}

.profile-edit-actions .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.profile-edit-actions .btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.profile-edit-actions .btn-secondary {
  background: #fff;
  border-color: #d1d5db;
  color: #1f2937;
}

.profile-edit-actions .btn-secondary:hover:not(:disabled) {
  background: #f3f4f6;
}

.profile-edit-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.profile-feedback {
  font-size: 14px;
  margin: -6px 0 6px;
}

.profile-feedback.is-success {
  color: #047857;
}

.profile-feedback.is-error {
  color: #b91c1c;
}

.profile-edit-toggle {
  margin: -6px 0 14px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #2563eb;
  color: #2563eb;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

.profile-edit-toggle:hover {
  background: #eff6ff;
}

/* ── Auth pages shared shell ─────────────────────────────────────── */

.auth-shell {
  display: flex;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: #111827;
}

.auth-subtitle {
  margin: 0 0 24px;
  font-size: 14px;
  color: #6b7280;
}

/* ── Login form ──────────────────────────────────────────────────── */

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field input:disabled {
  background: #f3f4f6;
  cursor: not-allowed;
}

.auth-error {
  margin: 12px 0;
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #b91c1c;
  font-size: 14px;
}

.auth-success {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  color: #047857;
  font-size: 14px;
}

.auth-footer {
  margin: 20px 0 0;
  text-align: center;
  font-size: 14px;
  color: #6b7280;
}

.auth-footer a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.required {
  color: #ef4444;
  font-weight: 700;
}

.auth-submit {
  width: 100%;
  padding: 11px 16px;
  margin-top: 4px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-submit:hover:not(:disabled) {
  background: #1d4ed8;
}

.auth-submit:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

/* ── Divider + Google button ─────────────────────────────────────── */

.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: #9ca3af;
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.auth-divider span {
  padding: 0 12px;
}

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.auth-google:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.auth-google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #4285f4, #34a853);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
  font-size: 13px;
}

/* ── Spinner (auth-callback) ─────────────────────────────────────── */

.auth-spinner {
  width: 28px;
  height: 28px;
  margin: 24px auto 0;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── ProfilePage ─────────────────────────────────────────────────── */

.profile-shell {
  padding: 40px 16px;
  display: flex;
  justify-content: center;
}

.profile-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 32px 28px;
}

.profile-title {
  margin: 0 0 20px;
  font-size: 22px;
  color: #111827;
}

.profile-fields {
  margin: 0 0 24px;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
}

.profile-fields dt {
  color: #6b7280;
  font-size: 14px;
}

.profile-fields dd {
  margin: 0;
  color: #111827;
  font-weight: 500;
}

.profile-logout {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid #ef4444;
  background: #fff;
  color: #ef4444;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.profile-logout:hover:not(:disabled) {
  background: #ef4444;
  color: #fff;
}

.profile-logout:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Admin pages (users + roles) ───────────────────────────────── */

.sidebar-section-label {
  color: #9ca3af;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 12px 6px;
}

.admin-shell {
  max-width: 1080px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 18px;
}

.admin-header h1 {
  margin: 0;
  font-size: 22px;
  color: #111827;
}

.admin-header .btn-primary {
  padding: 8px 14px;
  border-radius: 6px;
  background: #2563eb;
  border: 1px solid #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.admin-header .btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.admin-header .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

.admin-table thead th {
  background: #f9fafb;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.admin-table tbody tr:hover {
  background: #f9fafb;
}

.admin-row-actions {
  text-align: right;
  white-space: nowrap;
}

.admin-row-actions button {
  margin-left: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.admin-row-actions button:hover {
  background: #f3f4f6;
}

.admin-row-actions button.is-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.admin-row-actions button.is-danger:hover {
  background: #fef2f2;
}

.admin-form {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

.admin-form h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: #111827;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.admin-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #6b7280;
}

.admin-form-grid input,
.admin-form-grid select {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: #111827;
}

.admin-form-grid input:focus,
.admin-form-grid select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.admin-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.admin-form-actions .btn-primary,
.admin-form-actions .btn-secondary {
  padding: 8px 18px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
}

.admin-form-actions .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.admin-form-actions .btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.admin-form-actions .btn-secondary {
  background: #fff;
  border-color: #d1d5db;
  color: #1f2937;
}

.admin-form-actions .btn-secondary:hover:not(:disabled) {
  background: #f3f4f6;
}

/* ── Admin pagination (events / users / roles) ───────────────── */

.admin-pagination {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.admin-pagination button {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.admin-pagination button:hover:not(:disabled) {
  background: #f3f4f6;
}

.admin-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Audit log detail panel ──────────────────────────────────── */

.admin-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.admin-detail-header h2 {
  margin: 0;
  font-size: 18px;
  color: #111827;
}

.admin-payload {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
  margin: 0;
}

.admin-row-clickable {
  cursor: pointer;
}

.admin-row-clickable:hover {
  background: #f9fafb;
}

.admin-row-clickable.is-selected {
  background: #eff6ff;
}

/* Audit-timeline event-type cues (WA-4). The icon + Vietnamese label come
   from js/lib/event-labels.js; this colors the Type cell by kind. */
.event-kind-success  { color: #1a7f37; }
.event-kind-danger   { color: #cf222e; }
.event-kind-security { color: #8250df; font-weight: 600; }
.event-kind-neutral  { color: inherit; }
