/* =============================================
   WORKERSPANEL CUSTOM COMPONENTS
   No Bootstrap Conflicts - Works with Bootstrap 5
   ============================================= */

/* =============================================
   BUTTON ENHANCEMENTS (Work with Bootstrap)
   ============================================= */

/* Only enhance Bootstrap buttons, don't override */
.btn {
  font-weight: 800;
  transition: all 0.2s ease;
  border-width: 2px;
  border-radius: 12px;
  gap: 8px;
}

.btn:hover {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.btn:active {
  transform: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}



/* =============================================
   WP BUTTON BASE (Bootstrap + Non-Bootstrap)
   Ensures consistent buttons even on pages without Bootstrap (e.g., login/installer)
   ============================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-main);
}

.btn.btn-block { width: 100%; }
.btn.btn-left { justify-content: flex-start; }

.btn.btn-sm { min-height: 34px; padding: 0 10px; font-size: .9rem; border-radius: 10px; }
.btn.btn-xs { min-height: 28px; padding: 0 10px; font-size: .85rem; border-radius: 10px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { filter: brightness(1.05); }

.btn-secondary {
  background: var(--bg-panel);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: rgba(220, 53, 69, 0.18);
  border-color: rgba(220, 53, 69, 0.45);
  color: #ffb3bd;
}

.btn-danger:hover { background: rgba(220, 53, 69, 0.28); }

.btn:disabled, .btn.disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* =============================================
   PAGE LAYOUT COMPONENTS
   ============================================= */

.content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.content-title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 900;
}

.content-subtitle {
  margin: 0;
  color: var(--text-muted);
}

/* =============================================
   CUSTOM MODAL SYSTEM (Keep for now)
   ============================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-overlay > .modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-overlay > .modal > .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 12px 12px 0 0;
}

.modal-overlay > .modal > .modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-overlay .modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-overlay .modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.modal-overlay > .modal > .modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-overlay > .modal > .modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border-radius: 0 0 12px 12px;
}

/* =============================================
   CALENDAR SPECIFIC COMPONENTS
   ============================================= */

.calendar-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

/* =============================================
   BADGE COMPONENTS (Enhance Bootstrap badges)
   ============================================= */

.staff-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.staff-badge-remove {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.staff-badge-remove:hover {
  background: var(--accent);
  color: #000;
}

/* =============================================
   FORM GROUP SPACING (Enhance Bootstrap forms)
   ============================================= */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-main);
}

/* =============================================
   EVENT FIELDS VISIBILITY SYSTEM
   ============================================= */

.event-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#runsFields,
#meetingsFields,
#holidaysFields,
#generalFields,
#commonFields {
  display: none;
}

/* =============================================
   STAFF SELECTOR COMPONENT
   ============================================= */

.selected-staff {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  padding: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.selected-staff:empty::before {
  content: "No staff selected";
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* =============================================
   UTILITY CLASSES (Non-conflicting)
   ============================================= */

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* =============================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ============================================= */

@media (max-width: 768px) {
  .modal-overlay > .modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    animation: none;
  }

  .modal-header,
  .modal-overlay > .modal > .modal-footer {
    border-radius: 0;
  }

  .content-header {
    flex-direction: column;
    gap: 12px;
  }

  .calendar-container {
    padding: 12px;
    border-radius: 8px;
  }
}

/* =============================================
   APP FOUNDATION UTILITIES (used across pages)
   These classes were referenced in templates but
   were missing, causing broken layouts.
   ============================================= */


/* Spacing helpers */
.mt-sm{margin-top:8px !important;}
.mt-md{margin-top:14px !important;}
.mt-lg{margin-top:22px !important;}
.mb-sm{margin-bottom:8px !important;}
.mb-md{margin-bottom:14px !important;}
.mb-lg{margin-bottom:22px !important;}

/* Flex helpers (non-bootstrap names used in templates) */
.align-center{align-items:center !important;}
.justify-between{justify-content:space-between !important;}
.gap-sm{gap:8px !important;}
.gap-md{gap:12px !important;}
.gap-lg{gap:16px !important;}

/* Grid helpers */
.grid{display:grid;gap:16px;}
.grid-2{display:grid;gap:16px;grid-template-columns:repeat(2,minmax(0,1fr));}
.grid-3{display:grid;gap:16px;grid-template-columns:repeat(3,minmax(0,1fr));}
.grid-4{display:grid;gap:16px;grid-template-columns:repeat(4,minmax(0,1fr));}

/* Stat cards (used on Maintenance / Overview) */
.stat-card{
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px 16px;
  display:flex;
  align-items:center;
  gap:12px;
  min-height:76px;
}
.stat-icon{
  width:40px;
  height:40px;
  border-radius:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border);
  font-size:1.15rem;
  flex-shrink:0;
}
.stat-label{
  font-size:0.78rem;
  color:var(--text-muted);
  text-transform:uppercase;
  letter-spacing:0.06em;
  font-weight:750;
}
.stat-value{
  font-size:1.08rem;
  font-weight:900;
  margin-top:2px;
}

/* Permissions UI */
.perm-grid{gap:14px;}
.perm-group{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,0.02);
  overflow:hidden;
}
.perm-group summary{
  cursor:pointer;
  list-style:none;
  padding:12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font-weight:850;
  letter-spacing:0.2px;
  background:var(--bg-panel);
  border-bottom:1px solid var(--border);
}
.perm-group summary::-webkit-details-marker{display:none;}
.perm-group summary::after{
  content:"▾";
  color:var(--text-muted);
  display:inline-block;
  transform:translateY(-1px);
}
.perm-group[open] summary::after{content:"▴";}

.perm-role{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,0.01);
  overflow:hidden;
  margin-bottom:14px;
}
.perm-role summary{
  cursor:pointer;
  list-style:none;
  padding:12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font-weight:850;
  letter-spacing:0.2px;
  background:var(--bg-panel);
  border-bottom:1px solid var(--border);
}
.perm-role summary::-webkit-details-marker{display:none;}
.perm-role summary::after{
  content:"▾";
  color:var(--text-muted);
  display:inline-block;
  transform:translateY(-1px);
}
.perm-role[open] summary::after{content:"▴";}
.perm-role-body{padding:14px;}
.perm-count{
  font-size:0.78rem;
  color:var(--text-muted);
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border);
  border-radius:999px;
  padding:2px 8px;
}
.perm-items{padding:12px 14px;display:grid;gap:8px;}
.perm-item{display:flex;align-items:flex-start;gap:10px;line-height:1.25;}
.perm-item input{margin-top:2px;}

/* Permissions UI: role-title toggle (no per-category collapse) */
.perm-role-header{gap:14px;}
.perm-role-toggle{
  appearance:none;
  border:none;
  background:transparent;
  padding:0;
  margin:0;
  color:inherit;
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  flex:1;
  cursor:pointer;
  text-align:left;
}
.perm-role-title{
  font-size:1.06rem;
  font-weight:900;
  letter-spacing:0.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  min-width:0;
}
.perm-role-toggle::after{
  content:"▾";
  color:var(--text-muted);
  display:inline-block;
  transform:translateY(-1px);
  margin-left:6px;
}
.perm-role-card.collapsed .perm-role-toggle::after{content:"▸";}
.perm-role-card.collapsed .perm-role-card-body{display:none;}

.perm-group-card{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,0.02);
  overflow:hidden;
}
.perm-group-header{
  padding:12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font-weight:850;
  letter-spacing:0.2px;
  background:var(--bg-panel);
  border-bottom:1px solid var(--border);
}


@media (max-width: 1100px){
  .grid-4{grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media (max-width: 900px){
  .grid-3{grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media (max-width: 768px){
  .grid-2,.grid-3,.grid-4{grid-template-columns:1fr;}
}

/* Card system (works for both raw markup and Bootstrap cards) */
.card{
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px;
  box-shadow:0 12px 30px rgba(0,0,0,0.18);
}
.card .card-body{padding:0;}

.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  margin:-16px -16px 16px;
  border-bottom:1px solid var(--border);
  background:var(--bg-panel);
  border-radius:14px 14px 0 0;
}

.card-title{
  margin:0;
  font-size:1.05rem;
  font-weight:850;
  letter-spacing:0.2px;
}

/* Tables */
table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

table thead th{
  text-align:left;
  font-size:0.78rem;
  letter-spacing:0.08em;
  text-transform:uppercase;
  color:var(--text-muted);
  background:var(--bg-panel);
  padding:12px 14px;
  border-bottom:1px solid var(--border);
}

table tbody td{
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  color:var(--text-main);
  vertical-align:top;
}

table tbody tr:hover td{
  background:rgba(255,255,255,0.02);
}

.table-compact th,
.table-compact td{
  padding:10px 12px;
}

/* Text */
.text-muted{color:var(--text-muted) !important;}
.small{font-size:0.9rem;}

/* Alerts (templates use alert-success + alert-error) */
.alert{
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.02);
  margin:0 0 16px;
}
.alert-success{
  border-color:rgba(16,185,129,0.35);
  background:rgba(16,185,129,0.12);
  color:#c7f9ea;
}
.alert-warning{
  border-color:rgba(245,158,11,0.35);
  background:rgba(245,158,11,0.12);
  color:#ffe7bf;
}
.alert-error,
.alert-danger{
  border-color:rgba(239,68,68,0.35);
  background:rgba(239,68,68,0.12);
  color:#ffd1d1;
}

/* Inputs used by profile/settings templates */
.form{display:flex;flex-direction:column;gap:14px;}
.input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--bg-panel);
  color:var(--text-main);
}
.input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgba(255,140,26,0.18);}

/* Buttons helpers */
.btn-xs{padding:6px 10px !important;font-size:0.82rem !important;border-radius:10px !important;}
.btn-left{display:inline-flex;align-items:center;justify-content:center;gap:8px;}

/* Badges */
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-weight:700;
  font-size:0.78rem;
  letter-spacing:0.02em;
}
.badge-info{background:rgba(59,130,246,0.18);border:1px solid rgba(59,130,246,0.35);color:#cfe3ff;}
.badge-success{background:rgba(16,185,129,0.18);border:1px solid rgba(16,185,129,0.35);color:#c9ffe8;}
.badge-danger{background:rgba(239,68,68,0.18);border:1px solid rgba(239,68,68,0.35);color:#ffd1d1;}
.badge-muted{background:rgba(255,255,255,0.06);border:1px solid var(--border);color:var(--text-main);}

/* Fix Bootstrap modal class conflicts for our custom modal-overlay system */
.modal-overlay .modal{
  position:relative !important;
  inset:auto !important;
  display:flex !important;
  flex-direction:column;
  width:100%;
  max-width:680px;
  margin:0;
  transform:none !important;
  pointer-events:auto;
}

/* Make overlay sit above sticky header */
.modal-overlay{z-index:2000;}



/* Shared "section title" used across admin/management cards */
.maint-section-title{
  margin:0;
  font-size:1.15rem;
  font-weight:900;
  letter-spacing:0.2px;
  display:inline-flex;
  align-items:center;
  gap:10px;
}

/* If a card header uses a subtitle paragraph, keep it neat + consistent */
.card-header p{
  margin:0;
  color:var(--text-muted);
  font-size:0.9rem;
}

/* Responsive helpers */
.table-wrap{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  border-radius:12px;
}
.table-wrap table{
  min-width: 740px;
}
@media (max-width: 900px){
  .table-wrap table{min-width: 680px;}
}

/* =============================================
   TRUTRAK DASHBOARD MODULE
   Makes the Management → TruTrak section feel like one cohesive block
   ============================================= */

.tt-live-header{
  align-items:flex-start;
}

.tt-live-subtitle{
  margin:6px 0 0 0;
  color:var(--text-muted);
  font-size:0.9rem;
}

.tt-live-meta{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

.tt-meta-item{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  color:var(--text-muted);
  font-size:0.82rem;
  letter-spacing:0.02em;
}

.tt-meta-item strong{
  color:var(--text-main);
  font-weight:900;
}

.tt-live-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.tt-filterbar{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin: 6px 0 12px;
}

.tt-searchbox{
  position:relative;
  flex: 1 1 360px;
  max-width: 720px;
}

.tt-searchbox .tt-search-icon{
  position:absolute;
  left:12px;
  top:50%;
  transform:translateY(-50%);
  opacity:.7;
  pointer-events:none;
}

.tt-searchbox input{
  padding-left: 36px;
}

.tt-filter-advanced{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,0.02);
  margin-bottom:12px;
}

.tt-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
}
@media (max-width: 520px){
  .table-wrap table{min-width: 620px;}
}

.mobile-only-block{display:none !important;}
@media (max-width: 900px){
  .mobile-only-block{display:block !important;}
}

/* Mobile staff cards */
.staff-cards{display:flex;flex-direction:column;gap:12px;}
.staff-card{
  background:var(--bg-panel);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
}
.staff-card-top{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;}
.staff-card-name{font-size:1.05rem;font-weight:900;letter-spacing:0.2px;}
.staff-card-sub{color:var(--text-muted);font-size:0.85rem;margin-top:2px;}
.staff-card-meta{display:grid;grid-template-columns:1fr;gap:10px;margin-top:12px;}
.meta-label{color:var(--text-muted);font-size:0.78rem;letter-spacing:0.08em;text-transform:uppercase;}
.meta-value{margin-top:4px;font-weight:650;}
.staff-card-actions{margin-top:14px;}

/* Map -> Vehicle Management deep-link highlight */
.row-highlight {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: 0 0 0 6px var(--accent-soft);
}


/* =============================================
   TRUTRAK MAP MARKERS (Leaflet divIcons)
   ============================================= */

.leaflet-div-icon{ background: transparent; border: none; }

.tt-pin{
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  border: 2px solid var(--c, #ff8c1a);
  background: rgba(0,0,0,0.55);
  box-shadow: 0 12px 24px rgba(0,0,0,0.35);
  user-select:none;
}

.tt-pin span{
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
}

.tt-pin.tt-van{ width: 36px; height: 36px; }
.tt-pin.tt-gf{ width: 32px; height: 32px; }

.tt-pin::after{
  content: "";
  position:absolute;
  inset:-4px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.03), 0 0 18px var(--glow, rgba(255,140,26,0.25));
  pointer-events:none;
}
