@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-page: #f4f7f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --border-color: #cbd5e1;
  --border-strong: #64748b;
  --text-main: #0f172a;
  --text-muted: #475569;
  --brand-primary: #0f766e;
  --brand-primary-hover: #115e59;
  --brand-light: #f0fdfa;
  --aamya-gold: #c6a462;
  --accent-blue: #1d4ed8;
  --accent-amber: #b45309;
  --accent-amber-bg: #fef3c7;
  --accent-red: #b91c1c;
  --accent-red-bg: #fee2e2;
  --accent-green: #15803d;
  --accent-green-bg: #dcfce7;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

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

[hidden] {
  display: none !important;
}

html {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-page);
  line-height: 1.5;
}

body {
  margin: 0;
  min-height: 100vh;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid #0b57d0;
  outline-offset: 2px;
}

/* Brand & Branch Logos */
.brand-logo-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 2px solid var(--aamya-gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.branch-logo-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  flex-shrink: 0;
}

.branch-logo-md {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 2px solid var(--border-color);
  flex-shrink: 0;
}

/* Native Modal Dialog rules (Modern Web Guidance) */
dialog {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: min(740px, 94vw);
  width: 100%;
  box-shadow: var(--shadow-md);
  color: var(--text-main);
  background: var(--bg-surface);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.dialog-body {
  padding: 1.5rem;
  max-height: 78vh;
  overflow-y: auto;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

/* Top Navigation Bar */
.topbar {
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 3px solid var(--aamya-gold);
}

.topbar.branch-theme {
  background: #0c4a6e;
  border-bottom-color: #38bdf8;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.topbar-badge {
  background: var(--aamya-gold);
  color: #0f172a;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-title {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 0;
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #e2e8f0;
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.card-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* Forms & Controls */
.form-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  margin-block-end: 1.1rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  font: inherit;
  font-size: max(1rem, 1em);
  padding: 0.6rem 0.8rem;
  min-height: 46px;
  border: 1.5px solid #64748b;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-main);
  width: 100%;
}

input:user-invalid,
select:user-invalid {
  border-color: var(--accent-red);
  background-color: #fff5f5;
}

fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 0 0 1.15rem 0;
}

legend {
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 42px;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  text-decoration: none;
}

@media (pointer: coarse) {
  .btn,
  input,
  select {
    min-height: 50px;
  }
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--brand-primary-hover);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: #64748b;
}
.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-danger {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border-color: #fca5a5;
}

.btn-sm {
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pharmacist {
  background: #ccfbf1;
  color: #115e59;
  border: 1px solid #99f6e4;
}
.badge-dispenser {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.badge-counter {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}
.badge-driver {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.badge-amber {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid #fcd34d;
}
.badge-green {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid #86efac;
}
.badge-red {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid #fca5a5;
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  padding: 0.55rem 1.05rem;
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.tab-btn[aria-selected="true"] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

/* ============================================================================
   STAGE 2: WEEKLY & MONTHLY ROTA GRID STYLES
   ============================================================================ */
.rota-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.rota-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-bottom: 1.25rem;
}

/* 2x2 Single-Screen Monthly Rota Grid (4 Weeks on One Screen) */
.monthly-rota-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .monthly-rota-grid {
    grid-template-columns: 1fr;
  }
}

.monthly-rota-grid .rota-wrapper {
  margin-bottom: 0;
}

.monthly-rota-grid .rota-table {
  min-width: 0;
  font-size: 0.72rem;
}

.monthly-rota-grid .rota-table th,
.monthly-rota-grid .rota-table td {
  padding: 0.22rem 0.28rem;
}

.monthly-rota-grid .rota-table thead th {
  min-width: 0 !important;
  padding: 0.28rem 0.25rem;
}

.monthly-rota-grid .rota-table tbody th {
  min-width: 118px;
  max-width: 135px;
}

.monthly-rota-grid .shift-box {
  min-height: 28px;
  padding: 0.18rem 0.25rem;
  border-radius: 5px;
}

.monthly-rota-grid .shift-box .mono {
  font-size: 0.7rem !important;
}

.monthly-rota-grid .badge {
  font-size: 0.62rem;
  padding: 0.08rem 0.35rem;
}

.rota-table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.rota-table th,
.rota-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  vertical-align: top;
}

.rota-table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 3;
  background: #0f172a;
  color: #ffffff;
  border-bottom: 2px solid var(--brand-primary);
}

.rota-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  background: #ffffff;
  min-width: 200px;
  max-width: 230px;
  border-right: 2px solid #cbd5e1;
}

.rota-status-row th,
.rota-status-row td {
  background: #f8fafc;
  vertical-align: middle;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid #cbd5e1;
}

.day-status-pill {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.76rem;
  line-height: 1.3;
}
.day-status-pill.red {
  background: #fee2e2;
  color: #991b1b;
  border: 1.5px solid #ef4444;
}
.day-status-pill.amber {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #f59e0b;
}
.day-status-pill.green {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.day-status-pill.closed {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.pharmacist-master-row th {
  background: #f0fdfa !important;
  color: #115e59;
}
.pharmacist-master-row td {
  background: #f0fdfa;
  border-bottom: 2px solid #0f766e;
}

.shift-box {
  border-radius: 7px;
  padding: 0.42rem 0.55rem;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  transition: transform 0.1s, box-shadow 0.1s;
}

.shift-box.interactive {
  cursor: pointer;
}
.shift-box.interactive:hover {
  box-shadow: 0 0 0 2px var(--brand-primary);
}

.shift-working-Pharmacist {
  background: #ccfbf1;
  color: #115e59;
  border: 1px solid #5eead4;
}
.shift-working-Dispenser {
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #93c5fd;
}
.shift-working-Counter {
  background: #f3e8ff;
  color: #581c87;
  border: 1px solid #d8b4fe;
}
.shift-working-Driver {
  background: #e2e8f0;
  color: #1e293b;
  border: 1px solid #94a3b8;
}

.shift-on-leave {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px dashed #f59e0b;
}
.shift-absent {
  background: #fee2e2;
  color: #991b1b;
  border: 1.5px dashed #ef4444;
}
.shift-cover-in {
  background: #ede9fe;
  color: #4c1d95;
  border: 1.5px solid #8b5cf6;
}
.shift-cover-out {
  background: #fff7ed;
  color: #9a3412;
  border: 1.5px dashed #fb923c;
}
.shift-off {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
}
.shift-closed {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

/* ============================================================================
   STAGE 3: LEAVE REQUEST CARDS & ANNUAL WALLCHART CALENDAR
   ============================================================================ */
.leave-req-card {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: #ffffff;
  margin-bottom: 0.85rem;
}

.leave-req-card.flagged {
  border-left: 5px solid #f59e0b;
  background: #fffbeb;
}

.calendar-months-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}

.month-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.85rem;
  background: var(--bg-subtle);
}

.month-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsive Data Table (Staff Directory) */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(680px, 82vh);
  container-type: inline-size;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.staff-dir-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.staff-dir-table th,
.staff-dir-table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.staff-dir-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #f1f5f9;
}

.staff-dir-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: #ffffff;
  font-weight: 700;
  border-right: 1px solid #e2e8f0;
}

@container (width < 640px) {
  .staff-dir-table,
  .staff-dir-table thead,
  .staff-dir-table tbody,
  .staff-dir-table tr,
  .staff-dir-table th,
  .staff-dir-table td {
    display: block;
  }

  .staff-dir-table thead {
    display: none;
  }

  .staff-dir-table tr {
    margin-block-end: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
  }

  .staff-dir-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #f1f5f9;
    border-right: none;
  }

  .staff-dir-table {
    --label-2: "Branch & Role";
    --label-3: "Contracted Pattern";
    --label-4: "Weekly Net Hrs";
    --label-5: "Admin Holiday Balance";
    --label-6: "PIN & Actions";
  }

  .staff-dir-table td:nth-child(2)::before {
    content: var(--label-2) ": ";
    font-weight: 700;
    color: var(--text-muted);
  }
  .staff-dir-table td:nth-child(3)::before {
    content: var(--label-3) ": ";
    font-weight: 700;
    color: var(--text-muted);
  }
  .staff-dir-table td:nth-child(4)::before {
    content: var(--label-4) ": ";
    font-weight: 700;
    color: var(--text-muted);
  }
  .staff-dir-table td:nth-child(5)::before {
    content: var(--label-5) ": ";
    font-weight: 700;
    color: var(--text-muted);
  }
  .staff-dir-table td:nth-child(6)::before {
    content: var(--label-6) ": ";
    font-weight: 700;
    color: var(--text-muted);
  }
}

.schedule-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr 130px 110px;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid #f1f5f9;
}

@media (max-width: 640px) {
  .schedule-row {
    grid-template-columns: 1fr 1fr;
  }
}

.login-shell {
  max-width: 1020px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.quick-account-card {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  background: var(--bg-subtle);
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  transition: border-color 0.15s, background-color 0.15s;
}

.quick-account-card:hover {
  border-color: var(--brand-primary);
  background: var(--brand-light);
}

.status-banner {
  padding: 0.85rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.status-banner.error {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid #fca5a5;
}
.status-banner.success {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid #86efac;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
  }
  .topbar,
  .no-print,
  .tabs-bar,
  .rota-toolbar {
    display: none !important;
  }
  .container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .rota-wrapper {
    overflow: visible !important;
    border: 1px solid #000 !important;
  }
  .rota-table {
    min-width: 100% !important;
    font-size: 8.5pt !important;
  }
  .rota-table thead th,
  .rota-table tbody th {
    position: static !important;
    background: #f1f5f9 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .shift-box,
  .day-status-pill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    min-height: 36px !important;
  }
}
