/* ===================== ROOT ===================== */
:root {
  --bg: #070c18;
  --card: rgba(20, 30, 55, 0.65);
  --muted: #9aa4b2;
  --text: #f1f6ff;

  --accent: linear-gradient(135deg, #3b82f6, #6366f1);
  --accent-solid: #4f8cff;

  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;

  --border: rgba(255, 255, 255, 0.1);

  --field-bg: rgba(255, 255, 255, 0.05);
  --field-bg-strong: #0f172a;
  --field-border: rgba(255, 255, 255, 0.1);
}

/* ===================== GLOBAL ===================== */
* {
  box-sizing: border-box;
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    color 0.25s ease,
    transform 0.25s ease,
    opacity 0.25s ease;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 140, 255, 0.15), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(99, 102, 241, 0.15), transparent 40%),
    linear-gradient(180deg, #050816, #0b1220);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  display: flex;
  min-height: 100vh;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: 260px;
  min-height: 100vh;
  height: 100vh;
  padding: 22px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.4px;
  margin-bottom: 20px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-top: 8px;
}

.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  flex: 1;
}

.sidebar .nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: 14px;
  font-weight: 500;
  color: var(--text);
}

.sidebar .nav a:hover {
  background: rgba(79, 140, 255, 0.15);
  transform: translateX(5px);
}

.sidebar .nav a.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
}

.sidebar .btn.red {
  margin-top: auto;
}

#logoutBtnSidebar {
  width: 100%;
}

/* ===================== ROLE VISIBILITY ===================== */
/* common navs always visible */
.nav-all {
  display: flex;
}

/* role based navs hidden by default */
.nav-admin,
.nav-worker,
.nav-driver,
.nav-recycling {
  display: none !important;
}

/* admin */
html[data-role="admin"] .nav-admin,
html[data-role="admin"] .nav-worker,
html[data-role="admin"] .nav-driver,
html[data-role="admin"] .nav-recycling {
  display: flex !important;
}

/* worker */
html[data-role="worker"] .nav-worker {
  display: flex !important;
}

/* driver */
html[data-role="driver"] .nav-driver {
  display: flex !important;
}

/* recycling manager */
html[data-role="recycling_manager"] .nav-recycling {
  display: flex !important;
}

.role-hidden {
  display: none !important;
}

/* ===================== MAIN ===================== */
.main {
  flex: 1;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0 0 10px;
}

.sub {
  color: var(--muted);
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 900px) {
  .container {
    display: block;
  }

  .sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

/* ===================== CARD ===================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  backdrop-filter: blur(12px);
  box-shadow:
    0 15px 40px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}

.card .label {
  color: var(--muted);
  font-size: 13px;
}

.card .value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 8px;
}

/* ===================== FORMS ===================== */
.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form .full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--text);
  outline: none;
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: rgba(241, 246, 255, 0.5);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(79, 140, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.2);
}

select option {
  background-color: var(--field-bg-strong);
  color: var(--text);
}

select option:disabled {
  color: rgba(241, 246, 255, 0.45);
}

/* ===================== BUTTONS ===================== */
.btn {
  padding: 12px 18px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 25px rgba(79, 140, 255, 0.35);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(79, 140, 255, 0.45);
}

.btn.red {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.35);
}

/* ===================== TABLE ===================== */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 12px;
}

.table tr {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
}

.table th,
.table td {
  vertical-align: middle;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  padding: 12px;
}

.table td {
  padding: 14px;
}

.table tr:hover {
  background: rgba(79, 140, 255, 0.1);
}

/* ===================== TASK TABLE FIX ===================== */
.table td.task-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.table td.task-actions .btn {
  margin: 0 !important;
}

.table td.task-id {
  white-space: nowrap;
}

.copy-btn {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}

/* ===================== SALARY TABLE ===================== */
.salary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.salary-table thead th,
.salary-table tbody td {
  text-align: center;
  vertical-align: middle;
  padding: 18px 14px;
}

.salary-table thead th {
  font-weight: 700;
  white-space: nowrap;
}

.salary-table tbody td {
  white-space: nowrap;
}

.salary-table th:nth-child(1),
.salary-table td:nth-child(1) {
  width: 18%;
}

.salary-table th:nth-child(2),
.salary-table td:nth-child(2) {
  width: 12%;
}

.salary-table th:nth-child(3),
.salary-table td:nth-child(3) {
  width: 22%;
}

.salary-table th:nth-child(4),
.salary-table td:nth-child(4) {
  width: 18%;
}

.salary-table th:nth-child(5),
.salary-table td:nth-child(5) {
  width: 30%;
}

/* ===================== PILLS ===================== */
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
}

.pill.good {
  background: rgba(34, 197, 94, 0.15);
  color: var(--good);
}

.pill.warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
}

.pill.bad {
  background: rgba(239, 68, 68, 0.15);
  color: var(--bad);
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: rgba(20, 30, 55, 0.95);
  border-radius: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 9999;
}

/* ===================== PROFILE DROPDOWN ===================== */
.profile-menu {
  position: relative;
}

.profile-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.profile-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 55px;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 180px;
  z-index: 999;
}

.profile-dropdown a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
}

.profile-dropdown a:hover {
  background: rgba(79, 140, 255, 0.15);
}

/* ===================== MODAL ===================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-content,
.modal-card {
  width: 420px;
  max-width: 95%;
  background: #0f1b2d;
  border-radius: 14px;
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 20px 50px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.25s ease;
}

.modal-content input {
  margin: 8px 0 16px 0;
}

@keyframes modalPop {
  from {
    transform: translateY(25px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-card .label {
  font-size: 13px;
  margin-top: 10px;
  margin-bottom: 4px;
  color: #9fb3d1;
}

.modal-card input,
.modal-card select,
.modal-card textarea {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #2a3f5f;
  background: #0a1422;
  color: #fff;
  outline: none;
  margin-bottom: 6px;
}

.modal-card input:focus,
.modal-card select:focus,
.modal-card textarea:focus {
  border-color: #4da3ff;
  box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.25);
}

.modal-card .btn {
  min-width: 100px;
}

body.modal-open {
  overflow: hidden;
}

/* ===================== AUTH ===================== */
.auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 140, 255, 0.25), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(34, 197, 94, 0.2), transparent 40%),
    linear-gradient(180deg, #050816, #0b1220);
  color: var(--text);
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(520px, 92vw);
  background: rgba(20, 30, 55, 0.8);
  border: 1px solid var(--border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
  padding: 22px;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.auth-footer {
  text-align: center;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.auth-card .btn {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 16px;
  margin-top: 6px;
}

.auth-card .btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.3);
}

.auth-card .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.chart-card {
  min-height: 320px;
}

.chart-card canvas {
  width: 100% !important;
  max-height: 260px;
  margin-top: 10px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.chart-card {
  min-height: 360px;
}

.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
  margin-top: 10px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.trend-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.trend-table th,
.trend-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #2d3d5a;
  text-align: left;
}

.empty-cell {
  text-align: center;
  opacity: 0.8;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}