/* ============================================================
   SimpleTimesheetPro — Global Stylesheet
   Blue tech theme. CSS custom properties for tenant branding.
   ============================================================ */

/* -- CSS Variables (defaults; overridden per-tenant inline) -- */
:root {
  --primary:       #1a73e8;
  --primary-dark:  #1558b0;
  --secondary:     #0d47a1;
  --accent:        #00bcd4;
  --accent-dark:   #0097a7;
  --sidebar:       #0d2137;
  --sidebar-hover: #132d4a;
  --sidebar-active:#1a73e8;
  --text-inv:      #ffffff;
  --text-main:     #1a1a2e;
  --text-muted:    #6b7280;
  --bg-main:       #f0f4f8;
  --bg-card:       #ffffff;
  --bg-input:      #f9fafb;
  --border:        #e2e8f0;
  --border-focus:  #1a73e8;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.14);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --sidebar-w:     260px;
  --topbar-h:      64px;
  --transition:    .18s ease;
  --danger:        #ef4444;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --info:          #3b82f6;
}

/* -- Reset -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; }

/* -- Login Page --------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 60%, var(--accent) 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 40px 36px 36px;
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.brand-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 14px;
}
.brand-logo {
  max-height: 60px;
  margin-bottom: 14px;
}
.login-brand h1 { font-size: 1.5rem; color: var(--text-main); margin-bottom: 4px; }
.login-brand p  { color: var(--text-muted); font-size: .9rem; }
.login-error {
  background: #fef2f2; color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 18px;
  display: none;
}
.login-error.show { display: block; }

/* -- App Shell ---------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* -- Sidebar ------------------------------------------------ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-h);
}
.sidebar-brand .brand-letter { width: 38px; height: 38px; font-size: 18px; border-radius: 10px; margin-bottom: 0; }
.sidebar-brand .brand-logo   { max-height: 38px; margin-bottom: 0; }
.sidebar-brand-text h2 { font-size: .95rem; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-brand-text p  { font-size: .72rem; color: rgba(255,255,255,.55); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-section { padding: 12px 16px 4px; font-size: .68rem; font-weight: 700; color: rgba(255,255,255,.35); letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.78);
  font-size: .875rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sidebar-nav a .nav-icon { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.sidebar-nav a .badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: .7rem; font-weight: 700; }
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: rgba(255,255,255,.5);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.85); }
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* -- Main Content ------------------------------------------ */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--text-main); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-time { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.page-content { padding: 28px; flex: 1; }
.page-header { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.page-header p   { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }

/* -- Cards -------------------------------------------------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; }

/* -- Stat Cards -------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}
.stat-card.accent::before  { background: var(--accent); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before  { background: var(--danger); }
.stat-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-main); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-sub   { font-size: .8rem; color: var(--text-muted); }
.stat-icon  { position: absolute; right: 18px; top: 20px; font-size: 1.8rem; opacity: .12; }

/* -- Grid layouts ------------------------------------------ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* -- Forms -------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: var(--text-main); }
.form-label span { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
  background: #fff;
}
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* -- Buttons ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-input); color: var(--text-main); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-accent    { background: var(--accent);    color: #fff; }
.btn-sm   { padding: 6px 14px; font-size: .8rem; }
.btn-lg   { padding: 12px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: 50%; aspect-ratio: 1; }
.btn-full { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* -- Table -------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1.5px solid var(--border);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 12px 16px; font-size: .875rem; }
.table-empty { text-align: center; padding: 48px; color: var(--text-muted); }

/* -- Badges ------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-muted   { background: #f1f5f9; color: #475569; }
.badge-running { background: #dcfce7; color: #15803d; animation: pulse-bg 1.5s ease infinite; }

@keyframes pulse-bg { 0%,100%{opacity:1} 50%{opacity:.7} }

/* -- Alerts ------------------------------------------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.alert-danger  { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }

/* -- Live indicator ---------------------------------------- */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: live-pulse 1.2s ease infinite;
}
@keyframes live-pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.5);opacity:.6} }

/* -- Timer display ----------------------------------------- */
.timer-display {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--primary);
  font-family: 'Courier New', monospace;
}
.timer-display.running { color: var(--success); }

/* -- Running tasks strip ----------------------------------- */
.running-strip {
  background: linear-gradient(90deg, var(--success) 0%, #16a34a 100%);
  color: #fff;
  padding: 8px 28px;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.running-strip strong { font-weight: 700; }

/* -- Modal -------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .18s ease;
}
@keyframes modal-in { from{transform:scale(.95);opacity:0} to{transform:scale(1);opacity:1} }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--text-muted); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--bg-main); }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* -- Tabs --------------------------------------------------- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 2px; }
.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* -- Search / Filter bar ----------------------------------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.filter-bar .form-control { min-width: 140px; flex: 1; }
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* -- Pagination -------------------------------------------- */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination .page-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-main);
  transition: background var(--transition), color var(--transition);
}
.pagination .page-btn:hover, .pagination .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* -- Toast -------------------------------------------------- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--text-main); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: .875rem;
  display: flex; align-items: center; gap: 10px;
  max-width: 340px;
  animation: toast-in .22s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger);  }
.toast.warning { background: var(--warning); color: #fff; }
@keyframes toast-in { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }

/* -- Spinner ------------------------------------------------ */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to{transform:rotate(360deg)} }
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.6);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}
.loading-overlay.show { display: flex; }

/* -- Scrollbar --------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* -- Utilities --------------------------------------------- */
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* -- Color swatch ------------------------------------------ */
.color-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.1); vertical-align: middle; }

/* -- Chart container --------------------------------------- */
.chart-wrap { position: relative; min-height: 220px; }
.chart-wrap canvas { max-height: 320px; }

/* -- Responsive -------------------------------------------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}
