/*
  intranet.css
  ============
  App-shell + component styles for the Profspect Intranet, built on top of
  the tokens in tokens.css. Dark glass theme, matching the marketing site's
  visual language but as an authenticated app shell (sidebar + topbar)
  rather than a marketing nav/footer.
*/

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ps-black);
  color: var(--ps-light);
  font-family: var(--font-body);
  min-height: 100vh;
}

a { color: var(--ps-blue); text-decoration: none; }
a:hover { color: var(--ps-teal); }

h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); color: var(--ps-white); }

/* ── App shell ─────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--ps-dark-2);
  border-right: 1px solid var(--ps-glass-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
}

.app-sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--ps-glass-border);
}
.app-sidebar-logo img { height: 32px; flex-shrink: 0; }
.app-sidebar-logo span { font-family: var(--font-heading); font-weight: 700; color: var(--ps-white); font-size: 1.05rem; white-space: nowrap; }

.app-nav { flex: 1; padding: 16px 12px; }
.app-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--ps-glass-border);
}
.app-nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ps-grey);
  padding: 12px 12px 6px;
  white-space: nowrap;
}

/* Section labels are now buttons that collapse their own link group. */
.app-nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}
.app-nav-section-toggle:hover { color: var(--ps-white); }
.app-nav-section-chevron { font-size: 0.95rem; transition: transform 0.2s ease; }
.app-nav-section.is-collapsed .app-nav-section-chevron { transform: rotate(-90deg); }
.app-nav-section.is-collapsed .app-nav-section-links { display: none; }

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--ps-grey);
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: var(--transition);
  white-space: nowrap;
}
.app-nav-link:hover { background: var(--ps-glass-bg-2); color: var(--ps-white); }
.app-nav-link.active {
  background: linear-gradient(135deg, rgba(111,203,239,0.16), rgba(46,230,201,0.12));
  color: var(--ps-white);
  border: 1px solid var(--ps-border);
}
.app-nav-link .mdi { font-size: 1.15rem; flex-shrink: 0; }

/* ── Collapsed sidebar (desktop) ──────────────────────────────────────── */

:root.sidebar-collapsed .app-sidebar { width: 76px; }
:root.sidebar-collapsed .app-sidebar-logo { justify-content: center; padding: 24px 10px; }
:root.sidebar-collapsed .app-sidebar-logo span,
:root.sidebar-collapsed .app-nav-section-label,
:root.sidebar-collapsed .nav-label { display: none; }
:root.sidebar-collapsed .app-nav-link { justify-content: center; padding: 10px; }
:root.sidebar-collapsed #sidebar-collapse-icon { transform: rotate(180deg); }

.sidebar-collapse-toggle { flex-shrink: 0; }
#sidebar-collapse-icon { display: inline-block; transition: transform 0.25s ease; }

@media (max-width: 900px) {
  .sidebar-collapse-toggle { display: none; }
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--ps-glass-bg);
  backdrop-filter: var(--ps-glass-blur);
  border-bottom: 1px solid var(--ps-glass-border);
}

.app-topbar-user { display: flex; align-items: center; gap: 12px; }

.app-topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--ps-glass-border);
  background: var(--ps-dark);
  color: var(--ps-grey);
}
.app-topbar-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ps-white);
  font-family: var(--font-body);
  font-size: 0.88rem;
}
.app-topbar-search input::placeholder { color: var(--ps-grey); }

.topbar-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--ps-dark-2);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  z-index: 20;
}
.topbar-search-results.is-open { display: block; }
.topbar-search-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--ps-grey);
  font-size: 0.88rem;
}
.topbar-search-results a:hover,
.topbar-search-results a.is-active { background: var(--ps-glass-bg-2); color: var(--ps-white); }
.topbar-search-results .topbar-search-empty { padding: 10px 14px; font-size: 0.85rem; color: var(--ps-grey); }

@media (max-width: 700px) {
  .app-topbar-search { display: none; }
}

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-full);
  border: 1px solid var(--ps-glass-border); background: transparent;
  color: var(--ps-grey); cursor: pointer; transition: var(--transition);
}
.theme-toggle:hover { color: var(--ps-white); background: var(--ps-glass-bg-2); }

.theme-option-group { display: flex; gap: 10px; }
.theme-option-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-md);
  border: 1px solid var(--ps-glass-border); background: var(--ps-dark);
  color: var(--ps-grey); cursor: pointer; transition: var(--transition);
}
.theme-option-btn.active {
  border-color: var(--ps-border); color: var(--ps-white);
  background: linear-gradient(135deg, rgba(111,203,239,0.16), rgba(46,230,201,0.12));
}

.app-content-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-content { padding: 28px; width: 100%; }

@media (max-width: 900px) {
  .app-sidebar { position: fixed; left: -280px; z-index: 40; transition: var(--transition); }
  .app-sidebar.is-open { left: 0; }
  .app-content { padding: 18px; }
}

/* ── Cards ─────────────────────────────────────────────────────────────── */

.glass-card {
  background: var(--ps-glass-bg);
  backdrop-filter: var(--ps-glass-blur);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.stat-card { text-align: left; }
.stat-card-number {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-card-label { color: var(--ps-grey); font-size: 0.85rem; margin-top: 4px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.mini-cal-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--ps-dark);
  border: 1px solid var(--ps-glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mini-cal-badge .mini-cal-day { font-size: 1rem; font-weight: 700; color: var(--ps-white); line-height: 1; }
.mini-cal-badge .mini-cal-month { font-size: 0.6rem; text-transform: uppercase; color: var(--ps-grey); }

.ps-divider { border: none; border-top: 1px solid var(--ps-glass-border); margin: 20px 0; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.ps-form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--ps-grey);
  margin-bottom: 6px;
  font-weight: 500;
}

.ps-form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ps-glass-border);
  background: var(--ps-dark);
  color: var(--ps-white);
  font-family: var(--font-body);
  transition: var(--transition);
}
.ps-form-control:focus {
  outline: none;
  border-color: var(--ps-blue);
  box-shadow: 0 0 0 3px rgba(111, 203, 239, 0.15);
}

.ps-form-group { margin-bottom: 16px; }
.ps-form-error { color: var(--ps-danger-light); font-size: 0.8rem; margin-top: 4px; }
.ps-form-check { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn-ps-primary, .btn-ps-outline, .btn-ps-ghost, .btn-ps-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ps-primary {
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-teal));
  color: var(--ps-black);
}
.btn-ps-primary:hover { box-shadow: var(--shadow-glow); color: var(--ps-black); }
.btn-ps-outline { background: transparent; border-color: var(--ps-border); color: var(--ps-blue); }
.btn-ps-outline:hover { background: var(--ps-glass-bg-2); color: var(--ps-teal); }
.btn-ps-ghost { background: transparent; color: var(--ps-grey); }
.btn-ps-ghost:hover { color: var(--ps-white); }
.btn-ps-danger { background: rgba(229, 72, 77, 0.15); color: var(--ps-danger-light); border-color: rgba(229,72,77,0.3); }
.btn-ps-danger:hover { background: rgba(229, 72, 77, 0.25); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ── Tables ────────────────────────────────────────────────────────────── */

.ps-table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--ps-glass-border); }
.ps-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.ps-table thead th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ps-grey);
  padding: 12px 16px;
  background: var(--ps-dark-2);
  position: sticky;
  top: 0;
}
.ps-table tbody td { padding: 12px 16px; border-top: 1px solid var(--ps-glass-border); font-size: 0.9rem; }
.ps-table tbody tr:hover { background: rgba(111, 203, 239, 0.05); }

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge-ps {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-ps-pending    { background: rgba(111, 203, 239, 0.15); color: var(--ps-blue-light); }
.badge-ps-approved,
.badge-ps-completed   { background: rgba(46, 230, 201, 0.15); color: var(--ps-teal-light); }
.badge-ps-rejected,
.badge-ps-overdue     { background: rgba(229, 72, 77, 0.15); color: var(--ps-danger-light); }
.badge-ps-cancelled,
.badge-ps-not-started { background: rgba(138, 147, 166, 0.15); color: var(--ps-grey); }
.badge-ps-in-progress { background: rgba(174, 230, 250, 0.15); color: var(--ps-blue-light); }

/* ── Progress bars ─────────────────────────────────────────────────────── */

.ps-progress {
  width: 100%;
  height: 8px;
  background: var(--ps-glass-bg-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.ps-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ps-blue), var(--ps-teal));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ── Avatars (topbar, settings, anywhere an employee is shown) ───────────── */

.ps-avatar {
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--ps-blue), var(--ps-teal));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ps-black);
  object-fit: cover;
  flex-shrink: 0;
}

/* ── Org chart (Mermaid) ──────────────────────────────────────────────── */

.mermaid-wrap { overflow-x: auto; }
.mermaid-wrap .mermaid { display: flex; justify-content: center; min-width: 600px; }

/* ── Flash messages ────────────────────────────────────────────────────── */

.ps-flash {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid var(--ps-glass-border);
}
.ps-flash-success { background: rgba(46, 230, 201, 0.1); color: var(--ps-teal-light); }
.ps-flash-danger  { background: rgba(229, 72, 77, 0.1); color: var(--ps-danger-light); }
.ps-flash-info    { background: rgba(111, 203, 239, 0.1); color: var(--ps-blue-light); }
.ps-flash-warning { background: rgba(255, 200, 87, 0.1); color: #FFD98A; }

/* ── Auth pages (login/2FA — no sidebar) ──────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, rgba(111,203,239,0.08), transparent 60%), var(--ps-black);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo img { height: 40px; }
.qr-wrap { text-align: center; margin: 16px 0; }
.qr-wrap img { border-radius: var(--radius-md); background: var(--ps-white); padding: 12px; }
.backup-codes {
  font-family: monospace;
  background: var(--ps-dark);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.85rem;
}

/* ── Welcome confetti (dashboard first-login celebration) ────────────── */

.ps-confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation-name: ps-confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes ps-confetti-fall {
  0%   { top: -10px; opacity: 0.9; }
  100% { top: 100vh; opacity: 0; }
}
