/* =============================================
   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: 600;
  transition: all 0.2s ease;
  border-width: 2px;
  border-radius: 8px;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: translateY(0);
}

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

/* =============================================
   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 {
  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-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-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.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-close:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

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

.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 {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    animation: none;
  }

  .modal-header,
  .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.
   ============================================= */

/* Visibility helpers */
.mobile-only{display:none !important;}

/* 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));}

/* 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:10px;}
.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));}
  .mobile-only{display:inline-block !important;}
}
@media (max-width: 768px){
  .grid-2,.grid-3,.grid-4{grid-template-columns:1fr;}
  .mobile-only{display:inline-block !important;}
}

/* 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;}

/* 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;}


/* 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;}
}
@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;}
