/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100%;
  margin: 0;
}

.user-edit-card { padding: 10px; }
.user-form-label {
    margin-bottom: .01rem;
    margin-top: .5rem;}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }
.link { color: var(--color-accent); }
.link:hover { text-decoration: underline; }

/* ── App layout ──────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-section {
  margin-bottom: 1rem;
}

.sidebar-section-label {
  display: block;
  padding: 0 1rem 0.35rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #475569;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  color: var(--color-sidebar-text);
  font-size: 14px;
  font-weight: 450;
  border-radius: 0;
  transition: var(--transition);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--color-sidebar-hover);
  color: #e2e8f0;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-sidebar-text-active);
  border-left-color: var(--color-accent);
  font-weight: 500;
}

.sidebar-link i {
  font-size: 15px;
  width: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--color-sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

a.sidebar-user-link {
  text-decoration: none;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.15s;
}

a.sidebar-user-link:hover {
  background: rgba(255,255,255,0.07);
  text-decoration: none;
}

a.sidebar-user-link .sidebar-user-name,
a.sidebar-user-link .sidebar-user-role {
  pointer-events: none;
}

.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent-button);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: #64748b;
}

.sidebar-logout-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  line-height: 1;
  font-size: 15px;
}

.sidebar-logout-btn:hover {
  color: #f87171;
  background: rgba(248,113,113,0.1);
}

/* ── Main content ────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--content-padding);
  max-width: 100%;
  min-width: 0;
}

/* ── Flash messages ──────────────────────────────────────────────────── */
.flash-container {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 450;
  border: 1px solid;
}

.flash-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.flash-error,
.flash-danger  { background: var(--color-danger-bg);  color: var(--color-danger);  border-color: var(--color-danger-border); }
.flash-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.flash-info    { background: var(--color-info-bg);    color: var(--color-info);    border-color: var(--color-info-border); }

.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* ── Login page ──────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.5rem;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0.5rem 0 0.25rem;
  color: var(--color-text);
}

.login-subtitle {
  color: var(--color-text-muted);
  margin: 0;
}

.alert-error {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
  border-radius: var(--radius);
  padding: 0.6rem 0.875rem;
  font-size: 13px;
  margin-bottom: 1.25rem;
}

.btn-primary-full {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--color-accent-button);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 1.25rem;
}
.btn-primary-full:hover { background: var(--color-accent-button-hover); }

.form-check-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* ── Error pages ─────────────────────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.error-code {
  font-size: 96px;
  font-weight: 800;
  color: var(--color-border);
  line-height: 1;
}

.error-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0.5rem 0;
}

.error-text {
  color: var(--color-text-secondary);
  margin-bottom: 2rem;
}

/* ── Utility ─────────────────────────────────────────────────────────── */
.text-muted   { color: var(--color-text-muted); }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-right   { text-align: right; }
.text-sm      { font-size: 12px; }
.font-medium  { font-weight: 500; }
.nowrap       { white-space: nowrap; }
.mt-4         { margin-top: 1.5rem; }
.d-inline     { display: inline; }

/* ── Sidebar close button (mobile only, hidden on desktop) ───────────── */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem;
  margin-left: auto;
  font-size: 18px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-close-btn:hover { color: #e2e8f0; }

/* ── Sidebar overlay backdrop ────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  backdrop-filter: blur(1px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay--visible {
  opacity: 1;
}

/* ── Mobile top bar ──────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
}

/* ── Body scroll lock when sidebar open ─────────────────────────────── */
body.sidebar-body-lock {
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE — tablet & mobile  (≤ 768px)
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar: hidden off-screen by default, slides in */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  /* Close button visible inside sidebar on mobile */
  .sidebar-close-btn {
    display: flex;
    align-items: center;
  }

  /* Overlay visible */
  .sidebar-overlay {
    display: block;
  }

  /* Main content: full width, no left margin */
  .main-content {
    margin-left: 0;
    padding: 0 1rem 1.5rem;
  }

  /* Mobile top bar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    margin: 0 -1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }

  .sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    font-size: 22px;
    line-height: 1;
    padding: 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
  }
  .sidebar-toggle:hover {
    color: var(--color-accent);
    background: var(--color-bg);
  }

  .mobile-topbar-brand {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
  }
  .mobile-topbar-brand i {
    color: var(--color-accent);
    font-size: 17px;
  }
  .mobile-topbar-brand:hover { text-decoration: none; color: var(--color-text); }

  .mobile-topbar-user {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
  }
}

/* ── Small mobile (≤ 480px) ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .main-content {
    padding: 0 0.75rem 1.5rem;
  }
  .mobile-topbar {
    margin: 0 -0.75rem 1rem;
    padding: 0.6rem 0.75rem;
  }
}
