/* Hotdesk design system — tokens + chrome + primitives.
   Shared by the manager panel (/admin), the member panel and the login/join
   screens, so a token here restyles the whole app at once. Keep pages free of
   bespoke colours: reach for these tokens and classes.

   Identity: warm-neutral surfaces (the app's "architectural paper" feel) with a
   single indigo accent for everything interactive, matched to the floor plan.
   Orange is the brand mark only. Light theme. */

:root {
  color-scheme: light;

  /* Warm neutrals — a hint of paper, never stark grey */
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --surface-3: #e9e5dd;
  --border: #e7e3d9;
  --border-2: #d8d2c5;
  --text: #23201b;
  --muted: #6b6559;
  --faint: #a49d8e;

  /* Indigo accent (matches the floor-plan selection colour exactly) */
  --accent: #4f46e5;
  --accent-2: #4338ca;
  --accent-soft: #eeecfd;
  --accent-ink: #3b31b8;
  --on-accent: #ffffff;

  /* Brand mark (logo, decorative dots) — not for interactive UI */
  --brand: #c96f2d;

  --danger: #dc2626;
  --danger-soft: #fdecec;
  --success: #16a34a;
  --success-soft: #e6f4ea;
  --warning: #d97706;
  --warning-soft: #fbeccd;

  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);

  --ring: 0 0 0 3px rgba(79, 70, 229, 0.22);
  /* Layered, soft shadows — the biggest single lift for a "modern" feel */
  --shadow-sm: 0 1px 2px rgba(51, 42, 20, 0.05), 0 1px 1px rgba(51, 42, 20, 0.03);
  --shadow: 0 10px 30px -14px rgba(51, 42, 20, 0.28), 0 2px 6px rgba(51, 42, 20, 0.06);
  --shadow-lg: 0 26px 60px -24px rgba(51, 42, 20, 0.34), 0 6px 16px rgba(51, 42, 20, 0.08);

  /* Accent as a light-catching gradient + a coloured lift, so primary surfaces
     read as raised glass rather than flat fills. */
  --accent-grad: linear-gradient(135deg, #5b52ec 0%, #4f46e5 52%, #4133c9 100%);
  --accent-shadow: 0 12px 26px -10px rgba(79, 70, 229, 0.55);

  /* Motion — one easing + duration scale the whole app animates on. */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 0.14s;
  --dur-2: 0.26s;
  --dur-3: 0.48s;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  /* Faint warm glow, so the page never reads as flat grey */
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(79, 70, 229, 0.05), transparent 60%),
    radial-gradient(1000px 480px at 100% 0%, rgba(201, 111, 45, 0.055), transparent 55%),
    var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 750; letter-spacing: -0.02em; }

/* Icons inherit text colour + size to the line box. */
svg { flex-shrink: 0; }
.ic-svg { width: 1.15em; height: 1.15em; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.admin-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: calc(11px + var(--safe-top)) 20px 11px;
  background: rgba(250, 249, 246, 0.82);
  -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.admin-topbar .brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.admin-topbar .brand img { width: 30px; height: 30px; border-radius: 9px; box-shadow: var(--shadow-sm); }
.admin-topbar .brand b { font-size: 15.5px; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; color: var(--text); }
.admin-topbar .brand span { color: var(--muted); font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-topbar .spacer { flex: 1; min-width: 0; }
.admin-topbar .who { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); min-width: 0; flex-shrink: 0; }
.admin-topbar .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.admin-topbar .who .avatar { flex-shrink: 0; }
#admin-logout { flex-shrink: 0; }
.admin-topbar .who .avatar {
  width: 31px; height: 31px; border-radius: 50%; object-fit: cover;
  background: var(--accent-soft); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--accent);
}
.admin-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 650; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .05s;
}
.admin-back:hover { background: var(--surface-2); border-color: var(--border-2); text-decoration: none; }
.admin-back:active { transform: scale(0.97); }
.admin-back .ic-svg { width: 16px; height: 16px; }
/* Icon-only variant — a shortcut that needs no name next to the switcher. */
.admin-back.icon { padding: 8px; }

/* View switcher — "Moje biuro" vs the management panel. These are the app's two
   surfaces, not links away from it: the current one is filled in, so where you
   are is readable at a glance. */
.hd-switch {
  display: inline-flex; flex-shrink: 0; gap: 2px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(51, 42, 20, 0.05);
}
.hd-switch-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 650; padding: 7px 14px;
  border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.hd-switch-btn .ic-svg { width: 15px; height: 15px; }
.hd-switch-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.7); }
.hd-switch-btn.active { background: var(--accent); color: #fff; box-shadow: 0 3px 10px -3px rgba(79, 70, 229, 0.55); }
.hd-switch-btn.active:hover { background: var(--accent); color: #fff; }

@media (max-width: 560px) {
  /* Keep the button labels on phones — they read better than bare icons. The bar
     wraps to two rows: brand on top, the switcher and actions packed below. */
  .admin-topbar { flex-wrap: wrap; gap: 8px; row-gap: 9px; padding-left: 14px; padding-right: 14px; }
  .admin-topbar .brand { flex: 0 0 auto; }
  .admin-topbar .spacer { flex-basis: 100%; height: 0; }
  .admin-topbar .who span { display: none; }
  .admin-back, #admin-logout { padding: 7px 12px; font-size: 12.5px; }
  .admin-back.icon { padding: 7px; }
  .hd-switch { margin-left: auto; }
  .hd-switch-btn { padding: 7px 11px; font-size: 12.5px; }
}

/* ---------- Layout ---------- */
.admin-main { max-width: 1120px; margin: 0 auto; padding: 26px 20px calc(48px + var(--safe-bot)); }
.admin-section-title { font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 4px 0 14px; }
@media (max-width: 560px) { .admin-main { padding: 18px 14px calc(36px + var(--safe-bot)); } }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 10px 17px; font-weight: 650; font-size: 14px;
  box-shadow: 0 1px 2px rgba(51, 42, 20, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: background .15s, transform .05s, box-shadow .15s, border-color .15s;
}
.btn:hover { background: var(--accent-2); text-decoration: none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .ic-svg { width: 16px; height: 16px; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost.danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn.ghost.danger:hover { background: var(--danger-soft); border-color: #f3c2c2; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }

/* Square icon-only button. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  box-shadow: var(--shadow-sm);
  transition: background .15s, color .15s, border-color .15s, transform .05s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #f3c2c2; }
.icon-btn .ic-svg { width: 18px; height: 18px; }

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.input, .textarea, select.input {
  width: 100%; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 16px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .textarea:hover, select.input:hover { border-color: var(--border-2); }
.input:focus, .textarea:focus, select.input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.textarea { resize: vertical; min-height: 90px; }
select.input { cursor: pointer; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em;
  background: var(--accent-soft); color: var(--accent-ink); }
.badge.ok { background: var(--success-soft); color: #15803d; }
.badge.muted { background: var(--surface-3); color: var(--muted); }
.badge.warn { background: var(--warning-soft); color: #b45309; }

/* ---------- Segmented tabs (shared by both panels) ---------- */
.hd-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: nowrap;
  padding: 5px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow-sm); }
.hd-tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border-radius: 999px;
  background: transparent; border: 0; color: var(--muted); font-weight: 650; font-size: 14px; cursor: pointer;
  transition: background .16s, color .16s;
  /* The bar spans the content width and its tabs share it evenly, so the nav
     scales with the layout on a wide screen instead of sitting as a small pill
     on the left. */
  flex: 1 1 0; white-space: nowrap; }
.hd-tab .ic-svg { width: 16px; height: 16px; }
.hd-tab:hover { color: var(--text); background: var(--surface-2); }
.hd-tab.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 10px -3px rgba(79, 70, 229, 0.5); }
/* A sub-toggle (Biurka/Salki) is a compact control, not a page-wide bar — keep
   it hugging its two tabs. */
.hd-subtabs { display: inline-flex; }
.hd-subtabs .hd-tab { flex: 0 0 auto; }
/* Narrow screens: one scrollable row rather than a wrapped block. Five tabs
   wrapping inside a rounded container read as a broken pill, not a control. */
@media (max-width: 760px) {
  .hd-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .hd-tabs::-webkit-scrollbar { display: none; }
  .hd-tab { flex: 0 0 auto; padding: 9px 14px; }
}

/* ---------- Hub tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color .18s, transform .1s, box-shadow .18s;
}
.tile:hover { text-decoration: none; border-color: var(--border-2); transform: translateY(-3px); box-shadow: var(--shadow); }
.tile .ico {
  width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 4px;
}
.tile .ico .ic-svg { width: 22px; height: 22px; }
.tile .t { font-size: 16px; font-weight: 750; }
.tile .d { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* ---------- Login gate ---------- */
.admin-gate { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.admin-gate .card { width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); padding: 30px; }
.admin-gate h1 { font-size: 22px; margin-bottom: 4px; }
.admin-gate .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }

/* ---------- Toast ---------- */
#admin-toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bot)); transform: translate(-50%, 160%);
  z-index: 9999; padding: 12px 20px; border-radius: 999px; font-weight: 650; font-size: 14px;
  background: #24201a; color: #fff; border: 1px solid transparent;
  box-shadow: var(--shadow-lg); transition: transform .32s cubic-bezier(.2,.8,.2,1); max-width: calc(100vw - 32px);
}
#admin-toast.show { transform: translate(-50%, 0); }
#admin-toast.err { background: var(--danger); }

.spin { width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: admspin .7s linear infinite; }
@keyframes admspin { to { transform: rotate(360deg); } }
.center-load { display: flex; align-items: center; justify-content: center; padding: 50px; }

/* ============================================================================
   Motion & polish — the 2026 refresh.
   A single entrance + micro-interaction system layered on the tokens above.
   Everything here is presentational; the block below hard-disables it for
   anyone who asked their OS for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-delay: 0ms !important;
    animation-iteration-count: 1 !important; transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes hd-fade-up   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes hd-fade-down { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes hd-pop       { 0% { transform: scale(.9); } 55% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes hd-shimmer   { to { background-position: -200% 0; } }

/* Page assembly: the bar drops in, the content rises under it. */
.admin-topbar { animation: hd-fade-down var(--dur-2) var(--ease-out) both; }
.admin-main   { animation: hd-fade-up var(--dur-3) var(--ease-out) both; }

/* Cards rise as they mount. Panels rebuild a card when their tab changes, so
   this doubles as a free tab transition. First few stagger into place. */
.card { animation: hd-fade-up var(--dur-3) var(--ease-out) both; }
.card + .card { animation-delay: .06s; }
.card + .card + .card { animation-delay: .12s; }

/* Segmented tabs: the tab bar fades in; the active pill rides the accent
   gradient and pops the moment it's chosen. */
.hd-tabs { animation: hd-fade-up var(--dur-3) var(--ease-out) both; animation-delay: .04s; }
.hd-tab { transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
.hd-tab:not(.active):active { transform: scale(.95); }
.hd-tab.active { background: var(--accent-grad); animation: hd-pop var(--dur-2) var(--ease); }

/* Primary buttons: gradient face, coloured lift, and a light sweep on hover.
   Ghost/danger/icon variants keep their own paint (higher specificity wins). */
.btn { background: var(--accent-grad); position: relative; overflow: hidden; }
.btn:hover { box-shadow: var(--accent-shadow); }
.btn::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255,255,255,.28) 50%, transparent 68%);
  transform: translateX(-130%); transition: transform .6s var(--ease);
}
.btn:hover::after { transform: translateX(130%); }
.btn.ghost::after, .btn.danger::after, .btn.ghost.danger::after { display: none; }

/* Icon buttons + tiles gain a small spring on hover. */
.icon-btn { transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
  border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.tile { animation: hd-fade-up var(--dur-3) var(--ease-out) both; }
.tile:nth-child(2) { animation-delay: .05s; } .tile:nth-child(3) { animation-delay: .1s; }
.tile:nth-child(4) { animation-delay: .15s; } .tile:nth-child(5) { animation-delay: .2s; }
.tile .ico { transition: transform var(--dur-2) var(--ease), background var(--dur-2) var(--ease); }
.tile:hover .ico { transform: scale(1.08) rotate(-3deg); }

/* Inputs settle their focus ring instead of snapping to it. */
.input, .textarea, select.input { transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), background var(--dur-1) var(--ease); }

/* Loading placeholder: a shimmer sweep any tab can drop in while it fetches. */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 200% 100%; animation: hd-shimmer 1.3s linear infinite; border-radius: var(--radius-sm); color: transparent !important; }

/* One consistent keyboard-focus ring across every interactive surface. */
:where(a, .hd-tab, .tile, .icon-btn, .admin-back):focus-visible { outline: none; box-shadow: var(--ring); }
