/*
 * app.css — Janitorial Systems shared layout & theme
 * Provides: CSS variables, body base, topbar, breadcrumb, buttons, status bar, utilities
 */

/* ── CSS Variables ───────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-primary:   #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary:  #f1f5f9;
  --bg-input:     #e2e8f0;

  /* Text */
  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #64748b;

  /* Borders */
  --border:       #cbd5e1;
  --border-light: #94a3b8;

  /* Accent (blue) */
  --accent:      #3b82f6;
  --accent-hover:#2563eb;
  --accent-soft: rgba(59, 130, 246, 0.15);

  /* Semantic */
  --success:      #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --warning:      #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger:       #ef4444;
  --danger-soft:  rgba(239, 68, 68, 0.15);

  /* Geometry */
  --radius:    8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow:    0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

body.dark {
  --bg-primary:   #0f1419;
  --bg-secondary: #1a2028;
  --bg-tertiary:  #242d38;
  --bg-input:     #2a3441;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --border:       #334155;
  --border-light: #475569;

  --shadow:    0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

/* Flash prevention for dark mode (applied before first paint) */
html.pre-dark,
html.pre-dark body { background: #0f1419 !important; }

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body base ───────────────────────────────────────────────────── */
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 40px;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  width: 100%;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.topbar-right .user-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.topbar-separator {
  color: var(--text-primary);
  margin: 0 8px;
  font-weight: 400;
}

.module-name {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ── Brand ───────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: color 0.15s;
}

.brand:hover span { color: var(--accent); }

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-icon svg { width: 18px; height: 18px; }

.brand span {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Breadcrumb ──────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 40px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Pushes toolbar to far right */
.breadcrumb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

.breadcrumb a:hover { color: var(--accent-hover); }

.breadcrumb-separator { color: var(--text-muted); }

.breadcrumb-current { color: var(--text-primary); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-ghost:hover { background: var(--bg-tertiary); }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }
.btn-ghost.danger:hover { background: var(--danger-soft); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.78rem;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--text-primary); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-input); }
.btn.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Status Bar ──────────────────────────────────────────────────── */
.status-bar {
  padding: 10px 40px;
  font-size: 0.85rem;
  font-weight: 500;
  flex-shrink: 0;
}
.status-bar.hidden    { display: none; }
.status-error   { background: var(--danger-soft);  color: var(--danger);  }
.status-success { background: var(--success-soft); color: var(--success); }
.status-info    { background: var(--accent-soft);  color: var(--accent);  }

/* Also support .status-bar.error / .success / .info variants used by admin */
.status-bar.error   { background: var(--danger-soft);  color: var(--danger);  }
.status-bar.success { background: var(--success-soft); color: var(--success); }
.status-bar.info    { background: var(--accent-soft);  color: var(--accent);  }

/* ── Utilities ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar     { padding: 0 16px; }
  .breadcrumb { padding: 6px 16px; }
  .status-bar { padding: 8px 16px; }
  .topbar-right .user-name { display: none; }
}
