/* ─────────────────────────────────────────────────────────────
   M&M – Main Stylesheet  (Black / White / Gray palette)
   ───────────────────────────────────────────────────────────── */

:root {
  --sidebar-bg:    #111111;
  --sidebar-w:     260px;
  --topbar-h:      64px;
  --accent:        #333333;
  --accent-hover:  #222222;
  --bg:            #f5f5f5;
  --card-bg:       #ffffff;
  --text:          #111111;
  --muted:         #666666;
  --border:        #e0e0e0;
  --radius:        12px;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 0 0 24px;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand i { color: #999; font-size: 1.3rem; }
.sidebar-logo {
  max-height: 56px;
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
/* Bootstrap's text-muted is too dark for our black sidebar — override it */
.sidebar .text-muted,
.sidebar-user .text-muted {
  color: rgba(255, 255, 255, .65) !important;
}
.sidebar-user .small {
  word-break: break-all;   /* long emails wrap instead of getting clipped */
}

.sidebar-nav {
  list-style: none;
  padding: 12px 12px;
  margin: 0;
  flex: 1;
}
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #999;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover  { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: #333; color: #fff; }
.sidebar-nav a i      { width: 18px; text-align: center; }
.sidebar-nav a.text-danger-soft { color: #999; }
.sidebar-nav a.text-danger-soft:hover { background: rgba(255,255,255,.06); color: #fff; }

/* ── Avatar ── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #333;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; }

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 99;
  transition: left .25s ease;
}
.topbar-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}
.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: none;
}
.sidebar-toggle:hover { background: var(--bg); }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px 28px;
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left .25s ease;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.form-card { max-width: 820px; }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.bg-blue   { background: #333; }
.bg-orange { background: #555; }
.bg-purple { background: #444; }
.bg-green  { background: #222; }
.bg-red    { background: #b02a37; }

.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }

/* ── Table ── */
.table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.table td { padding: 14px 16px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: #fafafa; }

/* ── Status badges ── */
.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-draft     { background: #f0f0f0; color: #555; }
.badge-submitted { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.badge-sent      { background: #e0e0e0; color: #333; }
.badge-paid      { background: #d0d0d0; color: #111; }

.badge-role-admin   { background: #111; color: #fff; }
.badge-role-manager { background: #555; color: #fff; }
.badge-role-worker  { background: #e0e0e0; color: #333; }

/* ── Buttons ── */
.btn-primary {
  background: #111 !important;
  border-color: #111 !important;
  color: #fff !important;
}
.btn-primary:hover { background: #333 !important; border-color: #333 !important; }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 6px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; opacity: .35; }
.empty-state p { font-size: 1rem; margin-bottom: 20px; }

/* ── Flash messages ── */
.flash-container { margin-bottom: 20px; }

/* ── Form section label ── */
.section-label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ── Line item rows ── */
.line-item-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px 90px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.line-total {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  font-size: .9rem;
}

/* ── Invoice total bar ── */
.invoice-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 20px;
  font-weight: 600;
}
.grand-total { font-size: 1.3rem; color: #111; }

/* ── Invoice paper (view page) ── */
.invoice-paper {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  max-width: 800px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
}
.invoice-brand { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.invoice-logo  { height: 56px; width: auto; display: block; }
.invoice-number-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.invoice-number { font-size: 1.3rem; font-weight: 700; color: var(--text); }

.invoice-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.meta-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 4px;
}
.meta-row {
  display: flex;
  gap: 16px;
  font-size: .9rem;
  margin-bottom: 4px;
}
.meta-row .meta-label { margin-bottom: 0; min-width: 90px; }

.invoice-table { margin-top: 8px; }
.invoice-table thead th {
  background: #fafafa;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.invoice-table tfoot td {
  border-top: 2px solid var(--border) !important;
  font-size: .95rem;
  padding-top: 16px;
}

.invoice-notes {
  background: #fafafa;
  border-radius: 8px;
  padding: 16px;
  margin-top: 24px;
}
.invoice-footer {
  margin-top: 40px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* ── Auth pages ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  background: #111;
}
/* Login background photo + dim overlay for readability */
.auth-page.login-bg {
  background-image:
    linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,.55)),
    url("/static/img/login-bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.auth-card {
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.auth-logo {
  font-size: 2.5rem;
  color: #333;
  text-align: center;
  margin-bottom: 16px;
}
.auth-logo-img {
  max-height: 90px;
  max-width: 100%;
  width: auto;
  display: inline-block;
}
.auth-title    { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-subtitle { text-align: center; color: var(--muted); margin-bottom: 28px; }
.auth-footer   { text-align: center; color: var(--muted); margin-top: 20px; font-size: .9rem; }
.auth-footer a { color: #333; text-decoration: none; font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar       { transform: translateX(-100%); }
  .sidebar.open  { transform: translateX(0); }
  .topbar        { left: 0; }
  .main-content  { margin-left: 0; padding: 16px; }
  .sidebar-toggle { display: block; }
  .line-item-row { grid-template-columns: 1fr 80px 100px 80px 36px; gap: 6px; }
  .invoice-paper { padding: 24px; }
  .stats-row     { grid-template-columns: 1fr 1fr; }
}

/* ── User management cards ── */
.user-mgmt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.user-mgmt-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.user-mgmt-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-mgmt-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #fafafa;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.user-mgmt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ── Worker cards (manager dashboard) ── */
.worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.worker-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  transition: box-shadow .2s;
}
.worker-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.worker-card--active {
  border-color: #333;
  background: linear-gradient(135deg, #fafafa, #fff);
}
.worker-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.worker-card__job {
  font-size: .85rem;
  color: var(--text);
  background: #f0f0f0;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 12px;
}
.worker-card__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.worker-card__stats .stat-label { font-size: .65rem; }
.worker-card__stats .fw-bold    { font-size: .95rem; }

/* ── Live badge ── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e0e0e0;
  color: #111;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #333;
  animation: pulse 1.5s infinite;
}

/* ── Invoice pipeline (admin) ── */
.stats-row .pipeline-card {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.pipeline-arrow {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0 4px;
}
.pipeline-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pipeline-value { font-size: 2rem; font-weight: 700; }
.text-purple     { color: #555; }

/* ── Timesheet clock widget ── */
.clock-active {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: linear-gradient(135deg, #111 0%, #222 100%);
  border-radius: var(--radius);
  color: #fff;
}
.clock-pulse {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #999;
  box-shadow: 0 0 0 0 rgba(153,153,153,0.6);
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(153,153,153,.6); }
  70%  { box-shadow: 0 0 0 10px rgba(153,153,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(153,153,153,0); }
}
.clock-label  { font-size: .7rem; font-weight: 700; letter-spacing: .1em; color: #bbb; }
.clock-job    { font-size: 1.2rem; font-weight: 700; }
.clock-since  { font-size: .85rem; color: #ccc; }
.clock-elapsed {
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
}
.clock-in-form { /* nothing extra needed */ }

/* ── Profile photo ── */
.profile-photo-wrap {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.profile-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-photo-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #333;
  color: #fff;
  font-size: 2.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border);
}

/* ── Print / PDF ── */
@media print {
  @page { margin: 18mm 16mm; size: A4; }

  /* Hide everything except the invoice */
  .sidebar, .topbar, .flash-container,
  .d-flex.gap-2.mb-4.flex-wrap,   /* action buttons row */
  .modal, .modal-backdrop, .no-print,
  .btn { display: none !important; }

  body { background: #fff !important; color: #111 !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }

  /* Make the invoice paper fill the full page */
  .invoice-paper {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  /* Keep logo colours accurate */
  .invoice-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Table colours in print */
  .invoice-table thead th {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Ensure page doesn't cut through rows */
  .invoice-table tr { page-break-inside: avoid; }
}
