/* ---- CSS Variables ---- */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #e4e0d8;
  --text: #1a1917;
  --text-muted: #6b6660;
  --accent: #1e3a5f;
  --accent-hover: #162d4a;
  --accent-light: #e8eef5;
  --success: #2d7a4f;
  --error: #c0392b;
  --error-bg: #fdecea;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.10);
  --transition: 0.2s ease;
}

body.dark {
  --bg: #111210;
  --surface: #1c1e1b;
  --surface2: #252724;
  --border: #2e302d;
  --text: #eceae4;
  --text-muted: #8a8880;
  --accent: #7eb3e8;
  --accent-hover: #9fc4f0;
  --accent-light: #1a2535;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 600; }
em { font-family: 'Fraunces', serif; font-style: italic; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-brand {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

.dark-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition);
}
.dark-toggle:hover { background: var(--border); }

/* ---- Login Page ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 860px;
  width: 100%;
  background: var(--surface);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.login-left {
  background: var(--accent);
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 480px;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  top: -80px; right: -80px;
}

.brand-badge {
  font-family: 'Fraunces', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.12);
  padding: 5px 12px;
  border-radius: 20px;
  width: fit-content;
  margin-bottom: auto;
}

.login-headline {
  font-size: 3rem;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 12px;
}

.login-sub {
  color: rgba(255,255,255,0.65);
  font-size: 0.95rem;
  line-height: 1.5;
}

.login-card {
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card h2 {
  font-size: 1.6rem;
  margin-bottom: 4px;
  color: var(--text);
}

.card-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.pw-wrapper {
  position: relative;
}

.pw-wrapper input { padding-right: 60px; }

.toggle-pw {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  text-decoration: none;
  width: 100%;
  text-align: center;
}

.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  padding: 12px 24px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Error / Messages ---- */
.error-msg {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #f5c6c2;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 18px;
}

.hidden { display: none !important; }

.hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---- Spinner ---- */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Page Content ---- */
.page-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ---- Profile ---- */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.avatar-ring {
  flex-shrink: 0;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4a7fbc);
  padding: 3px;
}

.avatar {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.profile-info h1 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.role-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.bio {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  max-width: 420px;
}

/* ---- Stats ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  animation: fadeUp 0.4s 0.1s ease both;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-num {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 2.4rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-footer-actions {
  display: flex;
  gap: 12px;
  animation: fadeUp 0.4s 0.2s ease both;
}

/* ---- Settings ---- */
.settings-header {
  margin-bottom: 32px;
  animation: fadeUp 0.4s ease both;
}

.settings-header h1 { font-size: 2rem; margin-bottom: 4px; }
.settings-header p { color: var(--text-muted); font-size: 0.95rem; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
  animation: fadeUp 0.4s 0.1s ease both;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 22px;
  color: var(--text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ---- Toggle Switch ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }

.toggle-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.toggle-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background var(--transition);
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---- Save row ---- */
.save-row {
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadeUp 0.4s 0.2s ease both;
}

.save-row .btn-primary { width: auto; }

.save-msg {
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 500;
  animation: fadeUp 0.3s ease both;
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .login-wrapper { grid-template-columns: 1fr; }
  .login-left { min-height: 200px; padding: 36px 32px; }
  .login-headline { font-size: 2rem; }
  .login-card { padding: 36px 32px; }

  .profile-hero { flex-direction: column; text-align: center; padding: 32px 24px; }
  .bio { max-width: 100%; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .profile-footer-actions { flex-direction: column; }
  .settings-grid { grid-template-columns: 1fr; }
  .navbar { padding: 0 20px; }
}