/* ---------------------------------------------------
   FacilitySync • Global Stylesheet with Theming
   © 2025 FacilitySync — All Rights Reserved.
----------------------------------------------------*/

/* THEME TOKENS (DEFAULT "DARK" THEME) */
:root {
  /* Backgrounds */
  --bg-body: #020617;
  --bg-header: #020617;
  --bg-card: #020617;
  --bg-card-elevated: #020617;

  /* Borders & surfaces */
  --border-subtle: #1f2937;
  --border-input: #334155;

  /* Text */
  --text-main: #f9fafb;
  --text-muted: #9ca3af;

  /* Status pills */
  --pill-open-bg: rgba(34,197,94,0.16);
  --pill-open-fg: #22c55e;

  --pill-busy-bg: rgba(248,113,113,0.16);
  --pill-busy-fg: #fca5a5;

  --pill-res-bg: rgba(59,130,246,0.16);
  --pill-res-fg: #bfdbfe;

  /* Buttons */
  --btn-primary-bg: #22c55e;
  --btn-primary-bg-hover: #16a34a;
  --btn-primary-fg: #022c22;

  --btn-ghost-bg: #020617;
  --btn-ghost-bg-hover: #111827;
  --btn-ghost-border: #4b5563;
  --btn-ghost-fg: #e5e7eb;

  --btn-danger-bg: #991b1b;
  --btn-danger-fg: #fee2e2;

  /* Pin gate overlay */
  --pin-overlay-bg: rgba(0,0,0,0.8);
  --pin-card-bg: #020617;
  --pin-border: #1f2937;
  --pin-input-border: #4b5563;
  --pin-error: #f87171;

  /* Shadows */
  --shadow-card: 0 18px 40px rgba(0,0,0,0.6);
  --shadow-card-strong: 0 32px 68px rgba(0,0,0,1);
}

/* GLOBAL RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 600;
}

/* HEADER */
header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

header span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* MAIN LAYOUT (dashboard + admin) */
main {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 16px;
}

/* Dashboard grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

/* Admin layout */
#adminMain {
  display: none; /* shown after PIN unlock via JS */
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 16px;
  display: none;
}

#adminMain.active {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
}

/* DASHBOARD CARDS */
.card {
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  padding: 14px 12px;
  min-height: 90px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.card-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.card-body {
  font-size: 0.95rem;
  font-weight: 500;
}

.card-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* STATUS PILLS */
.pill {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill-open {
  background: var(--pill-open-bg);
  color: var(--pill-open-fg);
}

.pill-busy {
  background: var(--pill-busy-bg);
  color: var(--pill-busy-fg);
}

.pill-reserved {
  background: var(--pill-res-bg);
  color: var(--pill-res-fg);
}

/* LAST UPDATED */
#lastUpdated {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

/* ADMIN PANEL CARDS */
.card-admin {
  background: var(--bg-card-elevated);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.card-admin h2 {
  font-size: 1rem;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* FORM LAYOUT */
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.field input,
.field select,
.field textarea {
  background: var(--bg-body);
  border: 1px solid var(--border-input);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text-main);
  font-size: 0.86rem;
}

.field textarea {
  resize: vertical;
  min-height: 60px;
}

/* BUTTONS */
.btn {
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.8rem;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0.08em;
  border: none;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.btn-primary:hover {
  background: var(--btn-primary-bg-hover);
}

.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-fg);
  border: 1px solid var(--btn-ghost-border);
}

.btn-ghost:hover {
  background: var(--btn-ghost-bg-hover);
}

.btn-danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-fg);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* TABLES */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.78rem;
}

.table th,
.table td {
  padding: 6px 8px;
  border-bottom: 1px solid #111827;
}

.table th {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* PIN GATE */
.pin-gate {
  position: fixed;
  inset: 0;
  background: var(--pin-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.pin-card {
  background: var(--pin-card-bg);
  padding: 24px;
  border: 1px solid var(--pin-border);
  border-radius: 18px;
  width: 290px;
  text-align: center;
  box-shadow: var(--shadow-card-strong);
}

.pin-card h2 {
  margin-bottom: 6px;
}

.pin-input {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--pin-input-border);
  background: var(--bg-body);
  color: var(--text-main);
  font-size: 1.2rem;
  letter-spacing: 0.35em;
  text-align: center;
}

.pin-error {
  color: var(--pin-error);
  margin-top: 8px;
  font-size: 0.85rem;
}

/* UTILITIES */
.message {
  margin-top: 8px;
  font-size: 0.8rem;
}

.hidden {
  display: none !important;
}
