/* frontend/assets/css/components.css */

/* =========================
   Buttons
========================= */
.btn{
  height:44px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:0 16px;
  border-radius:14px;
  cursor:pointer;
  font-weight:650;
  font-size:15px;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}
.btn:hover{ border-color:#d1d5db; }
.btn:active{ transform: translateY(1px); }

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

.btn-ghost{ background:transparent; }

.btn-sm{
  padding:8px 12px;
  border-radius:12px;
  height:44px; /* keep consistent height */
}

.btn-ghost.danger{ color: var(--accent-2); }

/* Toolbar/actions buttons consistent width */
.actions .btn{
  height:44px;
  padding:0 18px;
  min-width:120px;
  white-space:nowrap;
}

.icon-btn{
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  font-size:16px;
  display:grid;
  place-items:center;
}

/* =========================
   Pills / Badges
========================= */
.pill{
  padding:8px 12px;
  font-size:14px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:7px 11px;
  font-size:13px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
}
.badge.red{
  border-color: rgba(220,38,38,.35);
  background: var(--accent-weak);
  color: var(--accent-2);
}

/* Backend status pill states */
.pill.ok{
  border-color: rgba(16,185,129,.35);
  background: rgba(16,185,129,.10);
  color: #065f46;
}
.pill.bad{
  border-color: rgba(220,38,38,.35);
  background: var(--accent-weak);
  color: var(--accent-2);
}

/* =========================
   Cards
========================= */
.card{
  background:#fff;
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .card-h{
  padding:16px 16px 12px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.card .card-b{
  padding:16px;
  font-size:15px;
}

/* =========================
   Grid
========================= */
.grid{
  display:grid;
  gap:14px;
}

/* KPI grid default */
.grid.kpis{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 980px){ .grid.kpis{ grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px){ .grid.kpis{ grid-template-columns: repeat(2, 1fr); } }

/* Optional: 7 KPI cards row */
.grid.kpis.kpis-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.kpis.kpis-7 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 700px)  { .grid.kpis.kpis-7 { grid-template-columns: repeat(2, 1fr); } }

/* KPI Cards */
.kpi-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding:14px 14px 12px;
  display:flex;
  flex-direction:column;
  gap:6px;
  position:relative;
  overflow:hidden;
  min-height:76px;
}
.kpi-card::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  height:3px;
  width:100%;
  background: linear-gradient(90deg, var(--accent), rgba(220,38,38,.45));
}
.kpi-label{
  font-size:12px;
  color: var(--muted);
  letter-spacing:.08em;
  text-transform:uppercase;
  font-weight:750;
}
.kpi-value{
  font-size:22px;
  font-weight:900;
  letter-spacing:-.01em;
  line-height:1.1;
}
.kpi-foot{
  margin-top:auto;
  font-size:12px;
  color: var(--muted);
}

/* =========================
   Table
========================= */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border:1px solid var(--border);
  border-radius: 14px;
  background:#fff;
}
.table th, .table td{
  padding:13px 12px;
  border-bottom:1px solid var(--border);
}
.table td{ font-size:15px; }
.table th{
  text-align:left;
  font-size:13px;
  color:var(--muted);
  background:#fafafa;
  letter-spacing:.01em;
}
.table tr:last-child td{ border-bottom:none; }

/* Monthly muster compact table (fit 01..31 better) */
.table.table-muster{
  table-layout: fixed;
  width: 100%;
}
.table.table-muster th,
.table.table-muster td{
  padding: 6px 3px;
  font-size: 12px;
}
.table.table-muster th.day-col,
.table.table-muster td.day-col{
  width: 26px;
  text-align: center;
}
.table.table-muster th.name-col,
.table.table-muster td.name-col{
  width: 190px;
  white-space: nowrap;
  padding-right: 6px;
}

.name-main{ font-weight: 800; font-size: 13px; }
.name-sub{ color: var(--muted); font-size: 11px; margin-top: 2px; }

.cell-pill{
  display:inline-block;
  width: 22px;
  height: 20px;
  line-height: 20px;
  border-radius: 8px;
  font-weight: 900;
}

/* Cell highlights */
td.cell-absent .cell-pill{
  background: var(--accent-weak);
  color: var(--accent-2);
  border: 1px solid rgba(220,38,38,.30);
}
td.cell-weekoff .cell-pill{
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid rgba(107,114,128,.25);
}
td.cell-present .cell-pill{
  background: rgba(16,185,129,.12);
  color: #065f46;
  border: 1px solid rgba(16,185,129,.35);
}
td.cell-halfday .cell-pill{
  background: rgba(245,158,11,.14);
  color: #92400e;
  border: 1px solid rgba(245,158,11,.35);
}

/* =========================
   Inputs
========================= */
.input{
  width:100%;
  border:1px solid var(--border);
  border-radius:12px;
  padding:11px 12px;
  outline:none;
  font-size:15px;
}
.input:focus{
  border-color: rgba(220,38,38,.55);
  box-shadow: 0 0 0 4px rgba(220,38,38,.12);
}

/* =========================
   Sidebar UI
========================= */
.sb-header{
  display:flex;
  gap:12px;
  align-items:center;
  padding:12px 10px 14px;
}
.sb-logo{
  width:42px; height:42px;
  border-radius:12px;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  box-shadow: 0 10px 25px rgba(220,38,38,.18);
}
.sb-title{ font-weight:850; line-height:1.1; font-size:16px; }
.sb-sub{ font-size:13px; color:var(--muted); margin-top:3px; }

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:8px;
}
.nav .section{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
  padding:10px 10px 4px;
  text-transform:uppercase;
  letter-spacing:.08em;
}
.nav a{
  display:flex;
  gap:10px;
  align-items:center;
  padding:11px 10px;
  border-radius:12px;
  border:1px solid transparent;
  font-size:15px;
}
.nav a:hover{
  background:#fafafa;
  border-color: var(--border);
}
.nav a.active{
  border-color: rgba(220,38,38,.35);
  background: var(--accent-weak);
}
.nav .ico{
  width:30px;
  height:30px;
  display:grid;
  place-items:center;
  border-radius:10px;
  background:#fff;
  border:1px solid var(--border);
  font-size:15px;
}

/* Legacy collapsed hides (if you still use .sidebar.collapsed somewhere) */
.sidebar.collapsed .sb-text,
.sidebar.collapsed .sb-title-wrap,
.sidebar.collapsed .section{
  display:none;
}

/* =========================
   Toasts
========================= */
.toasts{
  position:fixed;
  right:16px;
  bottom:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
  z-index:999;
}
.toast{
  min-width: 260px;
  max-width: 380px;
  padding:13px 13px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  box-shadow: var(--shadow);
}
.toast .t{ font-weight:850; font-size:14px; }
.toast .d{ font-size:13px; color:var(--muted); margin-top:4px; }

/* API Status pill states (by id) */
#apiStatus.ok{
  border-color: rgba(16,185,129,.35);
  background: rgba(16,185,129,.12);
}
#apiStatus.bad{
  border-color: rgba(220,38,38,.35);
  background: rgba(220,38,38,.10);
}

/* =========================
   Modal System (fixed + clickable)
========================= */
.modal-wrap{
  position: fixed;
  inset: 0;
  z-index: 9998;
}

.modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  pointer-events: auto;
}

.modal{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100% - 24px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 50px rgba(0,0,0,.25);
  overflow: hidden;
  pointer-events: auto;
  z-index: 9999;
}

.modal *{ pointer-events: auto; }

/* =========================
   Users table actions
========================= */
.actions-row{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
}

/* =========================
   Employee Attendance History layout helpers
========================= */
.grid.two-col{
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
}
@media (max-width: 1100px){
  .grid.two-col{ grid-template-columns: 1fr; }
}

.emp-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 6px;
}
.emp-item{
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  user-select: none;
}
.emp-meta{
  display: flex;
  flex-direction: column;
}
.emp-name{
  font-weight: 700;
  font-size: 14px;
}

/* =========================
   Collapsible Sidebar Sections (layout.js)
========================= */
.sb-section{ margin-top: 10px; }

.sb-sec-h{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 10px 4px;
  border:0;
  background:transparent;
  cursor:pointer;

  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.08em;
  font-weight:750;
}
.sb-sec-h:hover{
  background:#fafafa;
  border-radius:12px;
  border:1px solid var(--border);
  padding:9px 9px 3px; /* compensate for border */
}

.sb-sec-caret{
  font-size:14px;
  line-height:1;
  opacity:.7;
}

.sb-sec-body{
  display:none; /* default collapsed */
  padding:6px 0 8px 0;
}
.sb-sec-body a{
  display:flex;
  gap:10px;
  align-items:center;
  padding:11px 10px;
  margin-top:6px;
  border-radius:12px;
  border:1px solid transparent;
  font-size:15px;
}
.sb-sec-body a:hover{
  background:#fafafa;
  border-color: var(--border);
}
.sb-sec-body a.active{
  border-color: rgba(220,38,38,.35);
  background: var(--accent-weak);
}
.sb-sec-body .ico{
  width:30px;
  height:30px;
  display:grid;
  place-items:center;
  border-radius:10px;
  background:#fff;
  border:1px solid var(--border);
  font-size:15px;
}
.sb-section.open .sb-sec-body{
  display:flex;
  flex-direction:column;
  gap:6px;
}

/* =========================
   Collapsed Sidebar (icons-only rail)
========================= */
#sidebar.collapsed{
  width: 74px; /* adjust if you want 64/72/80 */
}

/* Hide texts/caret/title in collapsed */
#sidebar.collapsed .sb-text,
#sidebar.collapsed .sb-sec-title,
#sidebar.collapsed .sb-sec-caret{
  display:none !important;
}

/* Section header centered */
#sidebar.collapsed .sb-sec-h{
  justify-content:center !important;
  padding:12px 0 !important;
}
#sidebar.collapsed .sb-sec-left{
  width:100%;
  justify-content:center !important;
}

/* Bigger icon box for section header */
#sidebar.collapsed .sb-sec-ico{
  width: 40px !important;
  height: 40px !important;
  border-radius: 14px !important;
  font-size: 18px !important;
}

/* Menu icons bigger/centered */
#sidebar.collapsed .sb-sec-body .ico,
#sidebar.collapsed .nav a .ico,
#sidebar.collapsed a .ico{
  width: 40px !important;
  height: 40px !important;
  border-radius: 14px !important;
  font-size: 18px !important;
  display: grid !important;
  place-items: center !important;
}

/* Center rows */
#sidebar.collapsed .nav a{
  justify-content:center !important;
  padding:10px 0 !important;
}

/* Keep children hidden in collapsed */
#sidebar.collapsed .sb-sec-body{
  display:none !important;
}

/* Keep active icon highlighted */
#sidebar.collapsed a.active{
  border-color: rgba(220,38,38,.35) !important;
  background: var(--accent-weak) !important;
}

/* =========================
   Global subtle red accent (Cards + Buttons)
   Paste at END of components.css
========================= */
/* =========================
   KPI / Data Cards only (kpi-card + mr-card)
   Subtle red accent = existing style
========================= */

/* Shared base */
.kpi-card,
.mr-card{
  position: relative;
  transition: box-shadow .15s ease, border-color .15s ease, transform .12s ease;
}

/* Accent strip (same concept as your kpi-card) */
.kpi-card::before,
.mr-card::before{
  content:"";
  position:absolute;
  left:0; top:0;
  width:100%;
  height:3px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, var(--accent), rgba(220,38,38,0));
  opacity:.85;
}

/* Hover accent only for KPI/Data cards */
.kpi-card:hover,
.mr-card:hover{
  border-color: rgba(220,38,38,.22);
  box-shadow: 0 12px 26px rgba(220,38,38,.08), var(--shadow);
  transform: translateY(-1px);
}

/* Attendance Search KPI tiles should behave like KPI/Data cards */
.as-kpi{
  position: relative;
  overflow: hidden;
  transition: box-shadow .15s ease, border-color .15s ease, transform .12s ease;
}

/* subtle accent strip (reuse your existing accent tokens) */
.as-kpi::before{
  content:"";
  position:absolute;
  left:0; top:0;
  width:100%;
  height:3px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, var(--accent), rgba(220,38,38,0));
  opacity:.85;
}

/* hover accent only for KPI tiles */
.as-kpi:hover{
  border-color: rgba(220,38,38,.22);
  box-shadow: 0 12px 26px rgba(220,38,38,.08), var(--shadow);
  transform: translateY(-1px);
}

/* Buttons: accent ONLY on hover (override old grey hover) */
.btn:hover{
  border-color: rgba(220,38,38,.28) !important;
  box-shadow: 0 8px 18px rgba(220,38,38,.06);
}


