/* ============================================================
   TimesheetPro – Stylesheet
   ============================================================ */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --info:          #0284c7;
  --info-light:    #e0f2fe;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px; color: var(--primary);
  text-decoration: none; white-space: nowrap;
}
.nav-brand svg { width: 22px; height: 22px; }
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius);
  color: var(--text-muted); text-decoration: none;
  font-weight: 500; transition: all .15s;
}
.nav-link:hover, .nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-badge { font-weight: 600; font-size: 13px; }
.role-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: .04em;
}
.role-admin   { background: #fce7f3; color: #be185d; }
.role-manager { background: #fef3c7; color: #92400e; }
.role-user    { background: #dbeafe; color: #1e40af; }

/* ── Layout ── */
.main-content { flex: 1; padding: 28px 32px; max-width: 1400px; margin: 0 auto; width: 100%; }
.footer { background: var(--surface); border-top: 1px solid var(--border); text-align: center; padding: 12px; color: var(--text-muted); font-size: 12px; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 700; font-size: 15px; }
.card-body { padding: 20px; }

/* ── Alerts ── */
.alert {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 20px; font-weight: 500;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger   { background: var(--danger-light);  color: var(--danger); }
.alert-warning  { background: var(--warning-light); color: var(--warning); }
.alert-info     { background: var(--info-light);    color: var(--info); }
.alert-close { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; padding: 0 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success);  color: #fff; }
.btn-success:hover  { filter: brightness(.9); }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover   { filter: brightness(.9); }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-ghost    { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover    { background: var(--bg); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-icon     { padding: 6px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-control.is-invalid { border-color: var(--danger); }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.tbl-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Status Badges ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-draft     { background: #f1f5f9; color: #64748b; }
.badge-submitted { background: var(--info-light);    color: var(--info); }
.badge-approved  { background: var(--success-light); color: var(--success); }
.badge-rejected  { background: var(--danger-light);  color: var(--danger); }

/* ── Page Headers ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-size: 22px; font-weight: 800; }
.page-sub   { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 4px; }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-primary { border-top: 3px solid var(--primary); }
.stat-success { border-top: 3px solid var(--success); }
.stat-warning { border-top: 3px solid var(--warning); }
.stat-danger  { border-top: 3px solid var(--danger); }

/* ── Timesheet Grid ── */
.ts-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-label { font-weight: 700; font-size: 15px; min-width: 200px; text-align: center; }

.ts-table { border-collapse: collapse; width: 100%; min-width: 820px; }
.ts-table th, .ts-table td { padding: 0; border: 1px solid var(--border); }
.ts-table thead th {
  background: var(--bg); padding: 8px 10px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  text-align: center; color: var(--text-muted);
}
.ts-table thead th.today { background: var(--primary-light); color: var(--primary); }
.th-project { text-align: left !important; min-width: 200px; }
.ts-table tbody td { vertical-align: middle; }
.ts-table tfoot td { background: var(--bg); font-weight: 700; padding: 8px 10px; }

.project-cell { padding: 8px 12px; }
.project-name { font-weight: 600; font-size: 13px; }
.project-customer { font-size: 11px; color: var(--text-muted); }

.hour-input {
  width: 100%; height: 40px; text-align: center;
  border: none; background: transparent; font-size: 14px;
  font-weight: 500; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hour-input:focus { outline: none; background: var(--primary-light); }
.hour-input::-webkit-inner-spin-button,
.hour-input::-webkit-outer-spin-button { opacity: 1; }

.row-total { padding: 8px 12px; font-weight: 700; text-align: right; background: #f8fafc; min-width: 60px; font-variant-numeric: tabular-nums; }
.col-total { font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

.ts-add-row { margin-top: 10px; }
.ts-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg); border-radius: var(--radius);
  margin-top: 16px; gap: 12px; flex-wrap: wrap;
}

.weekend-col { background: #fafafa; }
.notes-cell textarea {
  width: 100%; border: none; background: transparent;
  resize: none; font-size: 12px; padding: 6px 8px;
  font-family: inherit; color: var(--text-muted); min-height: 36px;
}
.notes-cell textarea:focus { outline: none; background: #fffbeb; }

/* ── Login Page ── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  padding: 24px;
}
.login-card { background: var(--surface); border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo svg { width: 48px; height: 48px; color: var(--primary); }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--primary); margin-top: 8px; }
.login-logo p { color: var(--text-muted); font-size: 13px; }

/* ── Admin Layout ── */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.admin-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; position: sticky; top: 76px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--text-muted); text-decoration: none; font-weight: 500;
  transition: all .15s;
}
.sidebar-link:hover, .sidebar-link.active { background: var(--primary-light); color: var(--primary); }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 10px 12px 4px; }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 12px; }  .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 520px; box-shadow: var(--shadow-md); }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 20px; }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile Nav ─────────────────────────────────────── */
.nav-hamburger {
  display: none; flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 6px; margin-left: auto;
}
.nav-hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: all .2s; }

.mobile-nav {
  display: none; flex-direction: column; gap: 2px;
  padding: 8px 16px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.mobile-nav.open { display: flex; }
.mobile-nav .nav-link { padding: 10px 12px; font-size: 15px; }
.mobile-nav-user {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-top: 1px solid var(--border); margin-top: 4px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  /* Layout */
  .main-content { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-title { font-size: 18px; }

  /* Navbar */
  .nav-links { display: none; }
  .nav-user { display: none; }
  .nav-hamburger { display: flex; }
  .navbar { padding: 0 16px; gap: 12px; }

  /* Cards */
  .card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .card-body { padding: 14px; }

  /* Forms */
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .modal-box { padding: 20px; margin: 0; max-height: 90vh; overflow-y: auto; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-box { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  /* Admin */
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }

  /* Timesheet */
  .ts-toolbar { gap: 8px; }
  .week-label { min-width: 0; font-size: 13px; }
  .ts-status-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .ts-status-bar .btn { text-align: center; justify-content: center; }

  /* Tables — horizontal scroll */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }

  /* Buttons */
  .btn { padding: 9px 14px; font-size: 13px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }

  /* Toast */
  #toast-container { bottom: 16px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }

  /* Review cards */
  .review-card .flex { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .week-label { font-size: 12px; }
  .page-title { font-size: 16px; }
}

/* ── Toast Notifications ──────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  font-size: 14px; font-weight: 500; max-width: 360px; min-width: 240px;
  opacity: 0; transform: translateX(30px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.toast-show { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--success); color: #fff; }
.toast-danger  { background: var(--danger);  color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast-info    { background: var(--primary); color: #fff; }
.toast-close {
  background: rgba(255,255,255,.25); border: none; border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1;
  color: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.toast-close:hover { background: rgba(255,255,255,.4); }

/* ── Inline Confirm ───────────────────────────────────────── */
.inline-confirm {
  position: absolute; right: 0; top: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  box-shadow: var(--shadow-md); z-index: 500;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-width: 260px; white-space: normal;
  animation: confirmPop .15s ease;
}
@keyframes confirmPop { from { opacity:0; transform:scale(.95) translateY(-4px); } to { opacity:1; transform:scale(1); } }
.inline-confirm-msg { font-size: 13px; font-weight: 600; flex: 1 1 100%; color: var(--text); }

/* ── Row flash highlight ──────────────────────────────────── */
@keyframes rowFlash { 0%,100% { background: transparent; } 50% { background: var(--primary-light); } }
.row-flash { animation: rowFlash .6s ease; }

/* ── Spinner in buttons ───────────────────────────────────── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
.btn-ghost .spinner { border-color: rgba(0,0,0,.2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Public Holidays ──────────────────────────────────────── */
.ts-table thead th.holiday {
  background: #ebebeb;
  color: #888;
}
.ts-table td.holiday-col {
  background: #f4f4f4;
}
.holiday-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #999;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72px;
}

/* ── Locked (submitted/approved) cell display ─────────────── */
.locked-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text);
}
