/* site.css - styles for the main layout and components of the app  */

/* Global color variables */
:root {
    --color-sidebar-bg: #1f2937; /* dark */
    --color-sidebar-text: #fff;
    --color-sidebar-link: #cbd5e1;
    --color-sidebar-link-active-bg: rgba(255,255,255,0.06);
    --color-topbar-bg: #fff;
    --color-topbar-border: #e5e7eb;
    --color-content-bg: #f8fafc;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
  --color-tooltip-bg: rgba(0,0,0,0.85);
  --color-tooltip-text: #fff;
  --color-backdrop: rgba(0,0,0,0.35);
  /* Form / UI palette */
  --color-input-border: #e5e7eb; /* match topbar border for subtle input outline */
  --color-button-primary: #0ea5a9; /* teal-ish accent to match site palette (visible on light bg) */
  --color-button-text: #ffffff;
  --color-error: #dc2626;
  /* Spacing tokens */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1.25rem;
  }

/* Make sizing predictable across components */
*, *::before, *::after { box-sizing: border-box; }

/* Login page styles (centralized so spacing is consistent) */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-content-bg);
  padding: calc(var(--space-lg) * 1.25);
}

/* Prevent the document from scrolling when showing the login page
  We use a helper class on the body rather than relying on descendant selectors. */
.no-scroll { overflow: hidden; }

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-topbar-bg);
  border: 1px solid var(--color-topbar-border);
  padding: var(--space-lg);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.login-card h1 { margin: 0 0 var(--space-md) 0; font-size: 1.25rem; color: var(--color-text-primary); }
.login-field { margin-bottom: var(--space-md); }
.login-field label { display:block; margin-bottom: var(--space-xs); color: var(--color-text-secondary); font-size: .9rem; }
.login-field input { width: 100%; padding: .5rem .6rem; border: 1px solid var(--color-input-border); border-radius: 6px; font: inherit; }

.login-actions { display:flex; align-items:center; margin-top: 0; width: 100%; }
.login-actions > div:last-child { display:flex; justify-content:flex-end; width: 100%; }
.login-actions button { background: var(--color-button-primary); color: var(--color-button-text); border: none; padding: .5rem .9rem; border-radius: 6px; cursor: pointer; }
.login-help { font-size: .85rem; color: var(--color-text-secondary); margin-right: var(--space-md); display:flex; align-items:center; gap: .5rem; }
.login-help input[type="checkbox"] { width: auto; margin: 0; }
.login-help label { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.login-help input[type="checkbox"] { vertical-align: middle; }
.error-msg { color: var(--color-error); margin-bottom: .6rem; }

.login-remember-text { white-space: nowrap; margin-left: .15rem; }

@media (max-width: 480px) {
  .login-actions { flex-direction: column; align-items: stretch; }
  .login-help { margin-right: 0; }
  .login-actions button { width: 100%; }
}

/* Background layer for login page images */
.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center center;
  filter: blur(6px) brightness(0.7);
  transform: scale(1.03);
}

/* ensure card sits above the background */
.login-page .login-card { position: relative; z-index: 10; }

.login-credit {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 60; /* above the card */
  font-size: .75rem;
  color: var(--color-text-primary);
  background: rgba(255,255,255,0.9);
  padding: .25rem .5rem;
  border-radius: 6px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}
.login-credit a { color: inherit; text-decoration: underline; }

@media (max-width: 480px) {
  .login-credit { left: 50%; right: auto; transform: translateX(-50%); }
}

/* Basic layout: left sidebar, top header, and content area */
html, body, .app {
  height: 100%;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  display: flex;
}

.sidebar {
  width: 220px;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  padding: 1rem;
  box-sizing: border-box;
}

.sidebar .logo {
  font-weight: bold;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
}

.sidebar nav li {
  margin: 0.5rem 0;
}

.sidebar nav a {
  color: var(--color-sidebar-link);
  text-decoration: none;
}

.sidebar nav a.active {
  color: var(--color-sidebar-text);
  background: var(--color-sidebar-link-active-bg);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}

.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-topbar-bg);
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-topbar-border);
}

.topbar .logo-img {
  height: 36px;
}

/* Hamburger button (hidden on wide screens) */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  margin-right: 0.5rem;
}

.top-right .username {
  margin-right: 0.75rem;
  font-weight: 600;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font: inherit;
}

.content {
  padding: 1.5rem;
  background: var(--color-content-bg);
  min-height: calc(100vh - 56px);
}

/* User menu dropdown */
.user-menu { position: relative; display: inline-block; }
.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--color-topbar-bg);
  border: 1px solid var(--color-topbar-border);
  padding: 0.5rem;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  min-width: 160px;
  z-index: 10000;
}
.user-menu-dropdown a, .user-menu-dropdown .btn-link {
  display: block;
  color: var(--color-text-primary);
  padding: 0.4rem 0.5rem;
  text-decoration: none;
}
.user-menu-dropdown .btn-link { background:none; border:none; text-align:left; width:100%; }
.user-menu.open .user-menu-dropdown { display: block; }

/* Avatar next to username */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 0.5rem;
}
/* Avatar tooltip: simple absolute tooltip under the avatar wrapper (no JS needed) */
.avatar-wrap[data-hint] { position: relative; display: inline-block; cursor: help; }
.avatar-wrap[data-hint]::after {
  content: attr(data-hint);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -2.6rem;
  white-space: nowrap;
  background: var(--color-tooltip-bg);
  color: var(--color-tooltip-text);
  padding: .35rem .6rem;
  border-radius: .25rem;
  font-size: .75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-in-out;
  z-index: 20000;
}
.avatar-wrap[data-hint]:hover::after,
.avatar-wrap[data-hint]:focus::after { opacity: 1; }

/* Desktop layout: fixed sidebar and header, scrollable content */
@media (min-width: 801px) {
  /* make sidebar fixed on desktop */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 220px;
    z-index: 1000;
  }

  /* main area sits to the right of the sidebar */
  .main {
    margin-left: 220px;
    min-height: 100vh;
    display: block; /* keep content flow inside main */
  }

  /* fix the topbar at the top of the main area */
  .topbar {
    position: fixed;
    left: 220px;
    right: 0;
    top: 0;
    height: 56px;
    z-index: 1100;
    display: flex;
    align-items: center;
  }

  /* content area below the topbar, scrollable independently */
  .content {
    margin-top: 56px;
    height: calc(100vh - 56px);
    overflow: auto;
  }
}

/* Responsive: on small screens, make sidebar overlay and show hamburger */
@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 9999;
    transition: left 0.22s ease-in-out;
  }

  .sidebar.open {
    left: 0;
  }

  /* backdrop to dim main content when sidebar open */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    z-index: 9998;
  }

  .main {
    margin-left: 0;
  }

  .hamburger {
    display: inline-block;
  }

  .content {
    padding: 1rem;
  }
}
