/* ═══════════════════════════════════════════════════════════
   DASHBOARD KIT — Admin Panel Redesign
   ═══════════════════════════════════════════════════════════ */

/* ── Override admin-screen base ── */
#admin-screen {
  max-width: 1100px;
  width: 100%;
  align-items: stretch;
}

/* ══════ DASHBOARD WRAPPER ══════ */
.dash-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ══════ TOP TOOLBAR ══════ */
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 18px 24px;
  border-bottom: none;
}

.dash-toolbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-toolbar-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--brand-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--brand-shadow);
  flex-shrink: 0;
}

.dash-toolbar-icon svg { width: 22px; height: 22px; color: #fff; }

.dash-toolbar-heading {
  font-size: 20px;
  font-weight: 900;
  color: #1e293b;
  line-height: 1.1;
}

.dash-toolbar-sub {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.dash-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ──── Toolbar Buttons ──── */
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .2s;
  white-space: nowrap;
}

.tbtn svg { width: 15px; height: 15px; }

.tbtn-default {
  background: #f8fafc;
  border-color: var(--border);
  color: #475569;
}
.tbtn-default:hover { background: #eeefff; border-color: #c7cbff; color: #2D3FE0; }

.tbtn-blue {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px var(--brand-shadow);
}
.tbtn-blue:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(45,63,224,.38); }

.tbtn-primary {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px var(--brand-shadow);
}
.tbtn-primary:hover { opacity: .9; transform: translateY(-1px); }

.tbtn-green {
  background: linear-gradient(135deg, #15803d, #22c55e);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(22,163,74,.25);
}
.tbtn-green:hover { opacity: .9; transform: translateY(-1px); }

.tbtn-amber {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(217,119,6,.22);
}
.tbtn-amber:hover { opacity: .9; transform: translateY(-1px); }

.tbtn-red {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.tbtn-red:hover { background: #fee2e2; border-color: #ef4444; }

.tbtn-ghost {
  background: transparent;
  border-color: var(--border);
  color: #94a3b8;
}
.tbtn-ghost:hover { color: #475569; background: #f8fafc; }

/* ══════ TABS ══════ */
.dash-tabs {
  display: flex;
  gap: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
  padding: 0 24px;
}

.dash-tab {
  padding: 13px 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  color: #94a3b8;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.dash-tab svg { width: 15px; height: 15px; }
.dash-tab:hover { color: #475569; }
.dash-tab.active { color: #2D3FE0; border-bottom-color: #2D3FE0; }

/* ══════ BODY ══════ */
.dash-body {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-top: 1px solid #e2e8f0;
  border-radius: 0 0 20px 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ══════ KPI CARDS ══════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.07); }

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon svg { width: 22px; height: 22px; color: #fff; }

.kpi-blue  .kpi-icon { background: var(--brand-grad); box-shadow: 0 4px 12px var(--brand-shadow); }
.kpi-green .kpi-icon { background: linear-gradient(135deg, #15803d, #4ade80); box-shadow: 0 4px 12px rgba(22,163,74,.28); }
.kpi-red   .kpi-icon { background: linear-gradient(135deg, #dc2626, #f87171); box-shadow: 0 4px 12px rgba(220,38,38,.25); }
.kpi-purple.kpi-icon { background: linear-gradient(135deg, #7c3aed, #a78bfa); box-shadow: 0 4px 12px rgba(124,58,237,.25); }

.kpi-info { flex: 1; min-width: 0; }
.kpi-num  { font-size: 30px; font-weight: 900; line-height: 1; color: #1e293b; font-variant-numeric: tabular-nums; }
.kpi-lbl  { font-size: 12px; color: #94a3b8; margin-top: 4px; font-weight: 600; }

.kpi-trend {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  align-self: flex-start;
  flex-shrink: 0;
}

.trend-up   { background: #dcfce7; color: #15803d; }
.trend-down { background: #fee2e2; color: #b91c1c; }
.trend-neu  { background: #f1f5f9; color: #64748b; }

/* ══════ SECTION HEADER ══════ */
.dash-section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.dash-section-title {
  font-size: 15px;
  font-weight: 800;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-section-title svg { width: 17px; height: 17px; color: #94a3b8; }

/* ══════ EMPLOYEE TABLE ══════ */
.emp-table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.emp-table-head {
  display: grid;
  grid-template-columns: 2.4fr 1.4fr 1fr 1fr 1fr auto;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.emp-table-row {
  display: grid;
  grid-template-columns: 2.4fr 1.4fr 1fr 1fr 1fr auto;
  padding: 13px 20px;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
  transition: background .15s;
  font-size: 13px;
}

.emp-table-row:last-child { border-bottom: none; }
.emp-table-row:hover { background: #f8fafc; }

/* Employee cell */
.emp-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.emp-cell img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color .2s;
}
.emp-cell img:hover { border-color: #a5b4fc; }

.emp-cell-info .emp-cell-name {
  font-weight: 700;
  color: #1e293b;
  font-size: 13px;
  line-height: 1.2;
}

.emp-cell-info .emp-cell-id {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-present {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.badge-present::before { background: #16a34a; box-shadow: 0 0 5px rgba(22,163,74,.5); }

.badge-absent {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
}
.badge-absent::before { background: #cbd5e1; }

/* Time cell */
.time-cell {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.time-cell svg { width: 13px; height: 13px; }
.time-in  { color: #15803d; }
.time-out { color: #b91c1c; }
.time-na  { color: #cbd5e1; font-size: 12px; }

/* Department tag */
.dept-tag {
  display: inline-block;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
}

/* PIN toggle */
.pin-toggle-btn {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  color: #94a3b8;
  cursor: pointer;
  transition: all .2s;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}
.pin-toggle-btn:hover { border-color: #f59e0b; color: #d97706; background: #fffbeb; }

/* Row actions */
.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
  color: #94a3b8;
}
.row-action-btn svg { width: 14px; height: 14px; }
.row-action-btn:hover { background: #eef0ff; border-color: #a5b4fc; color: #2D3FE0; }
.row-action-btn.danger:hover { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }

/* ══════ TODAY ACTIVITY BAR ══════ */
.activity-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
}

/* ══════ SEARCH BAR ══════ */
.dash-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.dash-search-input {
  flex: 1;
  min-width: 180px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: 'Cairo', sans-serif;
  color: #1e293b;
  outline: none;
  transition: border-color .2s;
}
.dash-search-input:focus { border-color: #2D3FE0; background: #fff; }
.dash-search-input::placeholder { color: #cbd5e1; }

.dash-search-select {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: 'Cairo', sans-serif;
  color: #475569;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}
.dash-search-select:focus { border-color: #2D3FE0; }

/* ══════ EMPTY STATE ══════ */
.dash-empty {
  padding: 48px;
  text-align: center;
  color: #cbd5e1;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.dash-empty svg { width: 36px; height: 36px; color: #e2e8f0; }

/* ══════ RESPONSIVE ══════ */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-toolbar { border-radius: 16px 16px 0 0; }
  .dash-body { padding: 16px; }
  .emp-table-head,
  .emp-table-row {
    grid-template-columns: 2fr 0fr 1fr 1fr 0fr auto;
  }
  .emp-table-head span:nth-child(2),
  .emp-table-row > *:nth-child(2),
  .emp-table-head span:nth-child(5),
  .emp-table-row > *:nth-child(5) { display: none; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dash-toolbar-actions .tbtn span { display: none; }
  .emp-table-head,
  .emp-table-row { grid-template-columns: 1fr 1fr auto; }
  .emp-table-head span:not(:nth-child(1)):not(:nth-child(3)):not(:nth-child(6)),
  .emp-table-row > *:not(:nth-child(1)):not(:nth-child(3)):not(:nth-child(6)) { display: none; }
  .kpi-trend { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   WHATSAPP NOTIFICATIONS PANEL
   ═══════════════════════════════════════════════════════════ */

.wa-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Status Banner ── */
.wa-status-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 16px;
  border: 1.5px solid;
  transition: all .3s;
}

.wa-active {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #86efac;
}

.wa-inactive {
  background: #f8fafc;
  border-color: var(--border);
}

.wa-status-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-active   .wa-status-icon { background: #16a34a; }
.wa-inactive .wa-status-icon { background: #94a3b8; }
.wa-status-icon svg { width: 22px; height: 22px; color: #fff; }

.wa-status-text { flex: 1; }
.wa-status-title {
  font-size: 15px;
  font-weight: 800;
  color: #1e293b;
}
.wa-status-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
}

/* Toggle Switch */
.wa-toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}

.wa-toggle-switch input { opacity: 0; width: 0; height: 0; }

.wa-toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 28px;
  transition: .3s;
}

.wa-toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 4px;
  right: 4px;
  transition: .3s;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.wa-toggle-switch input:checked + .wa-toggle-slider { background: #16a34a; }
.wa-toggle-switch input:checked + .wa-toggle-slider::before { right: 28px; }

/* ── Setup Guide ── */
.wa-setup-guide {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 14px;
  padding: 18px 20px;
}

.wa-guide-title {
  font-size: 14px;
  font-weight: 800;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.wa-guide-title svg { width: 16px; height: 16px; color: #d97706; }

.wa-guide-steps {
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wa-guide-steps li {
  font-size: 13px;
  color: #78350f;
  line-height: 1.7;
}

.wa-guide-steps code {
  background: rgba(217, 119, 6, .12);
  color: #92400e;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-family: monospace;
  direction: ltr;
  display: inline-block;
}

.wa-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: #d97706;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: color .2s;
}

.wa-guide-link:hover { color: #92400e; }
.wa-guide-link svg { width: 14px; height: 14px; }

/* ── Form Cards ── */
.wa-form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
}

.wa-form-title {
  font-size: 14px;
  font-weight: 800;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.wa-form-title svg { width: 16px; height: 16px; color: #94a3b8; }

.wa-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.wa-field { display: flex; flex-direction: column; gap: 6px; }

.wa-label {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.wa-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.wa-input-icon {
  position: absolute;
  right: 12px;
  color: #94a3b8;
  pointer-events: none;
}

.wa-input-icon svg { width: 15px; height: 15px; }

.wa-input {
  width: 100%;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 40px 10px 14px;
  font-size: 13px;
  font-family: 'Cairo', sans-serif;
  color: #1e293b;
  outline: none;
  transition: border-color .2s;
}

.wa-input:focus { border-color: #25d366; background: #fff; }
.wa-input::placeholder { color: #cbd5e1; }

/* ── Rules ── */
.wa-rules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.wa-rule-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all .2s;
}

.wa-rule-item:has(input:checked) {
  border-color: #86efac;
  background: #f0fdf4;
}

.wa-rule-item input { display: none; }

.wa-rule-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
}

.wa-rule-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-rule-icon svg { width: 16px; height: 16px; color: #fff; }
.wa-rule-in   { background: linear-gradient(135deg, #15803d, #4ade80); }
.wa-rule-out  { background: linear-gradient(135deg, #dc2626, #f87171); }
.wa-rule-late { background: linear-gradient(135deg, #d97706, #fbbf24); }

.wa-rule-title { font-size: 13px; font-weight: 700; color: #1e293b; }
.wa-rule-sub   { font-size: 11px; color: #94a3b8; margin-top: 3px; line-height: 1.5; }

/* Late hour row */
.wa-late-hour-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: #92400e;
  font-weight: 600;
}

.wa-late-hour-wrap svg { width: 16px; height: 16px; color: #d97706; }

.wa-hour-input {
  width: 60px;
  background: #fff;
  border: 1.5px solid #fde68a;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 15px;
  font-weight: 800;
  font-family: 'Cairo', sans-serif;
  color: #92400e;
  text-align: center;
  outline: none;
}

/* ── Actions Row ── */
.wa-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Log ── */
.wa-log-wrap {
  background: #0f172a;
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid #1e293b;
}

.wa-log-title {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}

.wa-log-title svg { width: 14px; height: 14px; }

.wa-log-list { display: flex; flex-direction: column; gap: 5px; }

.wa-log-row {
  display: flex;
  gap: 12px;
  font-size: 12px;
  font-family: monospace;
}

.wa-log-ts   { color: #475569; flex-shrink: 0; }
.wa-log-info { color: #94a3b8; }

.wa-log-empty {
  font-size: 12px;
  color: #334155;
  font-family: monospace;
  text-align: center;
  padding: 12px;
}

/* Responsive */
@media (max-width: 768px) {
  .wa-form-grid   { grid-template-columns: 1fr; }
  .wa-rules-grid  { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   AI ASSISTANT
   ═══════════════════════════════════════════════════════════ */
.ai-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 240px);
  min-height: 420px;
  gap: 0;
}
.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--brand-grad);
  border-radius: 16px 16px 0 0;
  color: #fff;
}
.ai-header-info { display:flex; align-items:center; gap:12px; }
.ai-header-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.15);
  display: flex; align-items:center; justify-content:center;
  font-size: 18px;
}
.ai-header-title { font-size:15px; font-weight:800; }
.ai-header-sub   { font-size:11px; opacity:.7; margin-top:1px; }
.ai-clear-btn {
  display: flex; align-items:center; gap:5px;
  background: rgba(255,255,255,.12); border: none; color:#fff;
  padding: 7px 12px; border-radius: 10px; cursor: pointer;
  font-size: 12px; font-weight: 700; transition: background .2s;
}
.ai-clear-btn:hover { background: rgba(255,255,255,.22); }

/* Feed */
.ai-feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  background: #f8fafc;
  border-left: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  scroll-behavior: smooth;
}

/* Welcome */
.ai-welcome {
  display: flex; flex-direction:column; align-items:center;
  justify-content: center; gap:10px; padding: 40px 20px;
  text-align: center;
}
.ai-welcome-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: var(--brand-grad);
  display: flex; align-items:center; justify-content:center;
  font-size: 28px; color:#fff; margin-bottom: 4px;
}
.ai-welcome-title { font-size:17px; font-weight:800; color:#1e293b; }
.ai-welcome-sub   { font-size:13px; color:#64748b; max-width:320px; line-height:1.5; }
.ai-chips { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:8px; }
.ai-chip {
  background: #fff; border: 1.5px solid #e2e8f0; color:#2D3FE0;
  padding: 7px 13px; border-radius: 20px; font-size:12px;
  font-weight: 700; cursor:pointer; transition: all .2s;
  font-family: inherit;
}
.ai-chip:hover { background:#eef0ff; border-color:#a5b4fc; }

/* Messages */
.ai-msg {
  display: flex; align-items:flex-end; gap:8px;
  margin-bottom: 14px;
}
.ai-msg-user { flex-direction: row-reverse; }

.ai-avatar {
  width: 30px; height: 30px; border-radius: 10px;
  background: var(--brand-grad);
  display: flex; align-items:center; justify-content:center;
  color:#fff; font-size:14px; flex-shrink:0;
}

.ai-bubble {
  max-width: 80%; padding: 11px 15px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.65;
}
.ai-bubble-user {
  background: var(--brand-grad);
  color: #fff; border-radius: 16px 16px 4px 16px;
}
.ai-bubble-bot {
  background: #fff; color: #1e293b;
  border: 1px solid #e2e8f0; border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.ai-bubble-error {
  background: #fff1f2; color: #be123c;
  border: 1px solid #fecdd3; border-radius: 16px;
}
.ai-bubble code {
  background: #f1f5f9; color:#2D3FE0; padding:1px 5px;
  border-radius: 5px; font-size: 12px;
}
.ai-bubble strong { color:#1e293b; }

/* Typing animation */
.ai-typing-bubble {
  display: flex; align-items:center; gap:5px; padding: 14px 18px;
}
.ai-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #94a3b8; animation: ai-bounce 1.2s infinite;
}
.ai-dot:nth-child(2) { animation-delay: .2s; }
.ai-dot:nth-child(3) { animation-delay: .4s; }
@keyframes ai-bounce {
  0%,60%,100% { transform:translateY(0); }
  30%          { transform:translateY(-6px); }
}

/* Input row */
.ai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 16px 16px;
}
.ai-input {
  flex: 1; border: 1.5px solid #e2e8f0; border-radius: 12px;
  padding: 10px 14px; font-size: 13.5px; resize: none;
  font-family: inherit; background: #f8fafc; color: #1e293b;
  outline: none; transition: border-color .2s; line-height: 1.5;
  max-height: 120px; overflow-y: auto;
}
.ai-input:focus { border-color: #a5b4fc; background:#fff; }
.ai-input:disabled { opacity: .5; }
.ai-send-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none;
  background: var(--brand-grad);
  color: #fff; cursor: pointer; display: flex;
  align-items:center; justify-content:center;
  font-size: 16px; flex-shrink:0; transition: opacity .2s;
}
.ai-send-btn:disabled { opacity:.4; cursor:default; }
.ai-send-btn:not(:disabled):hover { opacity:.85; }

/* ═══════════════════════════════════════════════════════════
   FULL RESPONSIVE — All Devices
   ═══════════════════════════════════════════════════════════ */

/* ── Base: make admin screen fluid ── */
#admin-screen {
  padding: 0 !important;
  border-radius: 0 !important;
  max-width: 1100px !important;
  min-height: auto;
}

.dash-wrap {
  min-height: auto;
}

/* ══════════════════════════════════════
   TABLET  ≤ 1024px
══════════════════════════════════════ */
@media (max-width: 1024px) {
  #admin-screen { max-width: 100% !important; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .dash-toolbar { padding: 14px 18px; gap: 10px; }
  .dash-toolbar-heading { font-size: 17px; }

  .emp-table-head,
  .emp-table-row {
    grid-template-columns: 2fr 1.2fr 1fr 1fr auto;
  }
  /* Hide PIN column on tablet */
  .emp-table-head span:nth-child(4),
  .emp-table-row > *:nth-child(4) { display: none; }

  .dash-body { padding: 18px; gap: 18px; }

  /* Tabs: scrollable strip */
  .dash-tabs {
    padding: 0 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .dash-tabs::-webkit-scrollbar { display: none; }
}

/* ══════════════════════════════════════
   MOBILE  ≤ 768px
══════════════════════════════════════ */
@media (max-width: 768px) {

  /* Toolbar stacks */
  .dash-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    border-radius: 0 !important;
    gap: 10px;
  }
  .dash-toolbar-title { justify-content: flex-start; }
  .dash-toolbar-heading { font-size: 16px; }
  .dash-toolbar-sub { font-size: 11px; }

  /* Action buttons: horizontal scroll — لا إخفاء للمحتوى */
  .dash-toolbar-actions {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
  }
  .dash-toolbar-actions::-webkit-scrollbar { display: none; }
  .dash-toolbar-actions .tbtn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
    gap: 5px;
    white-space: nowrap;
  }
  .dash-toolbar-actions .tbtn svg { width: 14px; height: 14px; }

  /* Tabs scrollable */
  .dash-tabs {
    padding: 0 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--border);
  }
  .dash-tabs::-webkit-scrollbar { display: none; }
  .dash-tab {
    padding: 11px 14px;
    font-size: 12px;
    gap: 5px;
  }

  /* Body */
  .dash-body {
    padding: 12px;
    gap: 14px;
    border-radius: 0 !important;
  }

  /* KPI 2 cols */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px 12px; gap: 10px; }
  .kpi-icon { width: 40px; height: 40px; border-radius: 12px; }
  .kpi-icon svg { width: 18px; height: 18px; }
  .kpi-num { font-size: 24px; }
  .kpi-trend { display: none; }

  /* Employee table → card style */
  .emp-table-head { display: none; }
  .emp-table-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 13px 14px;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
  }
  .emp-table-row > *:nth-child(1) { flex: 1; min-width: 0; order: 1; }
  .emp-table-row > *:nth-child(2) { order: 2; }
  .emp-table-row > *:nth-child(3) { display: none; }
  .emp-table-row > *:nth-child(4) { display: none; }
  .emp-table-row > *:nth-child(5) { display: none; }
  .emp-table-row > *:nth-child(6) { order: 3; margin-right: auto; }

  /* Search bar */
  .dash-search-bar { flex-direction: column; align-items: stretch; }
  .dash-search-select { width: 100%; }

  /* Section header */
  .dash-section-hd { flex-wrap: wrap; gap: 8px; }

  /* WA form grid */
  .wa-form-grid   { grid-template-columns: 1fr; }
  .wa-rules-grid  { grid-template-columns: 1fr; }

  /* AI chat */
  .ai-wrap { height: calc(100dvh - 280px); min-height: 320px; }

  /* Departments */
  .dept-grid { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════
   SMALL MOBILE  ≤ 480px
══════════════════════════════════════ */
@media (max-width: 480px) {
  /* Toolbar أزرار أصغر قليلاً — النص والأيقونة تبقى ظاهرة */
  .dash-toolbar-actions .tbtn {
    padding: 7px 10px;
    font-size: 11px;
  }

  /* KPI */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 12px 10px; gap: 8px; }
  .kpi-num { font-size: 20px; }
  .kpi-lbl { font-size: 11px; }
  .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
  .kpi-icon svg { width: 16px; height: 16px; }

  /* Body */
  .dash-body { padding: 10px; gap: 12px; }

  /* WA */
  .wa-status-banner { flex-direction: column; text-align: center; }

  /* AI */
  .ai-wrap { height: calc(100dvh - 260px); min-height: 280px; }
  .ai-msg { max-width: 92%; }
}

/* ══════════════════════════════════════
   LANDSCAPE PHONE  ≤ 768px + landscape
══════════════════════════════════════ */
@media (max-width: 768px) and (orientation: landscape) {
  .ai-wrap { height: calc(100dvh - 200px); min-height: 240px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ══════════════════════════════════════
   LARGE SCREEN  ≥ 1280px
══════════════════════════════════════ */
@media (min-width: 1280px) {
  #admin-screen { max-width: 1200px !important; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .prf-overview-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Touch: improve tap targets ── */
@media (hover: none) {
  .tbtn, .dash-tab, .row-action-btn, .prf-tab { min-height: 44px; }
  .row-action-btn { width: 36px; height: 36px; }
}

/* ── Safe area for notched phones ── */
.dash-toolbar { padding-top: max(18px, env(safe-area-inset-top)); }
.dash-body    { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

