/**
 * GeoAttend Pro reusable components — same vocabulary as the sibling TechAge ERPs
 * (.card, .stat-card, .filter-bar, .dtable, .badge, .empty-state, .section-header)
 * so markup patterns carry across projects.
 */

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); color: var(--text); }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-title { font-size: .9rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; color: var(--text); }
.card-title i { color: var(--muted); font-size: .85rem; }
.card-sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
a.card { transition: box-shadow .15s, transform .15s; display: block; }
a.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* ── Stat tiles ────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-card .stat-label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-card .stat-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-card .stat-value small { font-size: .9rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat-card .stat-foot { margin-top: 10px; font-size: .75rem; color: var(--muted); line-height: 1.5; }
.stat-card .stat-foot i { margin-right: 3px; }
.stat-card .stat-bar { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 12px; overflow: hidden; display: flex; }
.stat-card .stat-bar span { display: block; height: 100%; }
.icon-blue   { background: #e6eeff; color: #1d4ed8; }
.icon-green  { background: #dcfce7; color: #15803d; }
.icon-amber  { background: #fef3c7; color: #b45309; }
.icon-red    { background: #fee2e2; color: #b91c1c; }
.icon-violet { background: #ede9fe; color: #6d28d9; }
.icon-teal   { background: #ccfbf1; color: #0f766e; }
.icon-slate  { background: #eef2f7; color: #475569; }
html.dark .icon-blue { background: #172a55; color: #93b4ff; }
html.dark .icon-green { background: #0d3a2a; color: #6ee7b7; }
html.dark .icon-amber { background: #3d2a0a; color: #fcd34d; }
html.dark .icon-red { background: #401515; color: #fca5a5; }
html.dark .icon-violet { background: #2a1d52; color: #c4b5fd; }
html.dark .icon-teal { background: #0c3432; color: #5eead4; }
html.dark .icon-slate { background: #1e293b; color: #cbd5e1; }
.trend-up { color: #059669; font-weight: 700; }
.trend-down { color: #dc2626; font-weight: 700; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control, .form-select { display: block; width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; font-size: .875rem; font-family: inherit; color: var(--text); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.form-control:focus, .form-select:focus { outline: none; border-color: var(--pr); box-shadow: 0 0 0 3px rgba(15,42,95,.12); }
.form-control::placeholder { color: #a3adbf; }
.form-control[readonly] { background: var(--surface-2); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 88px; }
.form-hint { font-size: .74rem; color: var(--muted); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.input-group-text-x { position: relative; }
.input-group-text-x .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .78rem; pointer-events: none; }
.input-group-text-x .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.input-group-text-x .prefix + .form-control { padding-left: 30px; }
html.dark .form-control, html.dark .form-select { background: var(--surface-2); }

.password-field { position: relative; }
.password-field .form-control { padding-right: 42px; }
.password-toggle-btn { position: absolute; top: 0; right: 0; height: 100%; width: 42px; display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--muted); cursor: pointer; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; cursor: pointer; background: #cbd5e1; transition: background .18s; border-radius: 999px; }
.switch-slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; transition: transform .18s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .switch-slider { background: var(--ac); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .t { font-weight: 600; font-size: .85rem; }
.switch-row .d { font-size: .76rem; color: var(--muted); margin-top: 2px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: 10px; font-size: .82rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all .12s; text-decoration: none; white-space: nowrap; line-height: 1.2; font-family: inherit; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-sm { padding: 6px 11px; font-size: .76rem; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: .7rem; border-radius: 7px; gap: 5px; }
.btn-lg { padding: 13px 22px; font-size: .95rem; border-radius: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-primary { background: var(--pr); color: #fff !important; box-shadow: 0 1px 2px rgba(15,42,95,.25); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-accent, .btn-success { background: var(--ac); color: #fff !important; }
.btn-accent:hover, .btn-success:hover { filter: brightness(.95); }
.btn-outline { background: var(--surface); color: var(--text-2) !important; border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--pr); color: var(--pr) !important; }
.btn-ghost { background: transparent; color: var(--text-2) !important; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #dc2626; color: #fff !important; }
.btn-danger:hover { background: #b91c1c; }
.btn-soft-danger { background: #fef2f2; color: #b91c1c !important; border-color: #fee2e2; }
.btn-soft-danger:hover { background: #fee2e2; }
.btn-warning { background: var(--warn); color: #fff !important; }
html.dark .btn-soft-danger { background: #3a1414; border-color: #4c1d1d; color: #fca5a5 !important; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dtable { width: 100%; border-collapse: collapse; font-size: .82rem; }
.dtable th { padding: 11px 14px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); text-align: left; }
.dtable td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.dtable tbody tr { transition: background .1s; }
.dtable tbody tr:hover td { background: rgba(15,42,95,.025); }
.dtable tr:last-child td { border-bottom: 0; }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; white-space: nowrap; }
/* As a table cell it must stay a cell (flex breaks row borders and widths); its children line up inline instead. */
td.table-actions { display: table-cell; text-align: right; }
td.table-actions > * { display: inline-flex; vertical-align: middle; margin-left: 6px; }
td.table-actions > form { display: inline-block; }
html.dark .dtable tbody tr:hover td { background: rgba(255,255,255,.02); }

.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person .nm { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .sub { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.person:hover .nm { color: var(--pr); }
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.avatar-initials { color: #fff; font-weight: 700; letter-spacing: .02em; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .7rem; font-weight: 600; white-space: nowrap; line-height: 1.4; }
.badge i { font-size: .6rem; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #eef2f7; color: #475569; }
.badge-navy    { background: #e0e7ff; color: #3730a3; }
.badge-violet  { background: #ede9fe; color: #5b21b6; }
html.dark .badge-success { background: #0d3a2a; color: #86efac; }
html.dark .badge-danger { background: #401515; color: #fca5a5; }
html.dark .badge-warning { background: #3d2a0a; color: #fde68a; }
html.dark .badge-info { background: #172a55; color: #93c5fd; }
html.dark .badge-gray { background: #1e293b; color: #94a3b8; }
html.dark .badge-navy { background: #1e1b4b; color: #a5b4fc; }
html.dark .badge-violet { background: #2a1d52; color: #c4b5fd; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: .74rem; font-weight: 600; color: var(--text-2); }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 12px; font-size: .84rem; font-weight: 500; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid transparent; }
.alert i { margin-top: 2px; }
.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-error, .alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
html.dark .alert { filter: brightness(.85) saturate(.9); }

/* ── Page header / section header ──────────────────────────────────────── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.45rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.page-header .crumbs { font-size: .75rem; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.page-header .crumbs a { color: var(--muted); }
.page-header .crumbs a:hover { color: var(--pr); }
.page-header p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.1rem; gap: 12px; }
.section-header h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.section-header p { font-size: .8rem; color: var(--muted); margin: 2px 0 0; }
@media (max-width: 640px) {
  .page-header { align-items: stretch; }
  .page-actions .btn { flex: 1; }
}

/* ── Filter bar ────────────────────────────────────────────────────────── */
.filter-bar { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.filter-bar-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.filter-field { flex: 1 1 150px; min-width: 130px; }
.filter-field.filter-field-search { flex: 2 1 240px; }
.filter-field label { display: block; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 5px; }
.filter-clear { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; color: var(--muted) !important; padding: 8px 4px; white-space: nowrap; }
.filter-clear:hover { color: #dc2626 !important; }
.search-box { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 12px; display: flex; align-items: center; gap: 8px; height: 38px; transition: border-color .12s, box-shadow .12s; }
.search-box:focus-within { border-color: var(--pr); box-shadow: 0 0 0 3px rgba(15,42,95,.12); }
.search-box i { color: var(--muted); font-size: .8rem; }
.search-box input { background: transparent; border: none; outline: none; font-size: .84rem; color: var(--text); width: 100%; font-family: inherit; }
.filter-bar .form-control { height: 38px; padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 640px) { .filter-field { flex: 1 1 100%; } }

/* ── Tabs (segmented) ──────────────────────────────────────────────────── */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; flex-shrink: 0; }
.seg a, .seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; font-size: .78rem; font-weight: 600; color: var(--text-2); cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.seg a.active, .seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg .count { font-size: .68rem; background: var(--border); padding: 0 6px; border-radius: 99px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: .82rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--pr); border-bottom-color: var(--pr); }

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagi-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagi { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.pagi a, .pagi span { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 10px; border-radius: 8px; font-size: .78rem; font-weight: 600; color: var(--text-2); border: 1px solid var(--border); }
.pagi a:hover { border-color: var(--pr); color: var(--pr); }
.pagi a.current { background: var(--pr); color: #fff; border-color: var(--pr); pointer-events: none; }
.pagi a.disabled { opacity: .4; pointer-events: none; }
.pagi span { border: 0; }
.results-meta { font-size: .78rem; color: var(--muted); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state .icon { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--muted); margin-bottom: 14px; }
.empty-state .title { font-weight: 700; font-size: .95rem; margin-bottom: 4px; color: var(--text); }
.empty-state p { color: var(--muted); font-size: .82rem; margin: 0 auto; max-width: 360px; }

/* ── Modal (Bootstrap 5 overrides) ─────────────────────────────────────── */
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text); }
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 22px; gap: 8px; }
html.dark .btn-close { filter: invert(1); }

/* ── Progress / meter ──────────────────────────────────────────────────── */
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--ac); }

/* ── Activity feed ─────────────────────────────────────────────────────── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border); align-items: center; }
.feed li:last-child { border-bottom: 0; }
.feed .ev { flex: 1; min-width: 0; }
.feed .ev .t { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .ev .s { font-size: .73rem; color: var(--muted); }
.feed .tm { font-size: .72rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot-amber { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.dot-red { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.dot-blue { background: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; display: inline-block; position: relative; }
.live-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #10b981; animation: ga-ping 1.6s ease-out infinite; }
@keyframes ga-ping { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

/* ── Key/value list ────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: .83rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; color: var(--text); word-break: break-word; }

/* ── Calendar heat grid (staff profile) ────────────────────────────────── */
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat .hd { font-size: .66rem; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; }
.heat .c { aspect-ratio: 1; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 600; color: var(--muted); position: relative; }
.heat .c.present { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }
.heat .c.late { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.heat .c.absent { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.heat .c.holiday { background: #e0e7ff; border-color: #c7d2fe; color: #3730a3; }
.heat .c.off { opacity: .45; }
.heat .c.today { outline: 2px solid var(--pr); outline-offset: 1px; }
html.dark .heat .c.present { background: #0d3a2a; border-color: #115e44; color: #86efac; }
html.dark .heat .c.late { background: #3d2a0a; border-color: #5c3f0d; color: #fde68a; }
html.dark .heat .c.absent { background: #401515; border-color: #5c1f1f; color: #fca5a5; }
html.dark .heat .c.holiday { background: #1e1b4b; border-color: #312e81; color: #a5b4fc; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .72rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── Map ───────────────────────────────────────────────────────────────── */
.map-box { height: 320px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); z-index: 0; }
.leaflet-container { font-family: inherit; }

/* ── Loading overlay ───────────────────────────────────────────────────── */
#page-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.25); opacity: 0; visibility: hidden; transition: opacity .15s ease; backdrop-filter: blur(1px); }
#page-overlay.active { opacity: 1; visibility: visible; }
#page-overlay .spinner-ring { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: ga-spin .7s linear infinite; }
@keyframes ga-spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: ga-shimmer 1.4s infinite; border-radius: 6px; display: block; }
@keyframes ga-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Toastr (narrow phones) ────────────────────────────────────────────── */
@media (max-width: 420px) {
  #toast-container { width: calc(100vw - 24px); right: 12px !important; left: 12px !important; }
  #toast-container > div { width: 100% !important; }
}
#toast-container > div { border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 1; font-family: inherit; }

/* Print styles live in print.css */

/* Form fields may shrink inside grid columns (date inputs otherwise overflow narrow cards) */
.form-grid > *, .grid > * { min-width: 0; }
.form-control { min-width: 0; }
