/* VetWorx Solutions LLC — Mobile Web App Framework */
:root {
  --bg: #0a0a0f;
  --card: #12121a;
  --card-hover: #1a1a28;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --border: #1e1e2e;
  --tab-height: 60px;
  --header-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap-min: 44px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
}

/* Splash Screen */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-icon {
  width: 80px; height: 80px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700; color: #fff;
  margin-bottom: 16px;
  animation: splash-pulse 1.2s ease-in-out infinite;
}
@keyframes splash-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.splash-name { font-size: 18px; color: var(--text-secondary); font-weight: 500; }

/* Header */
.app-header {
  position: fixed; top: var(--safe-top); left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; z-index: 100;
}
.app-header h1 { font-size: 18px; font-weight: 600; flex: 1; }
.header-badge {
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

/* Main Content */
.app-content {
  padding-top: calc(var(--header-height) + var(--safe-top));
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  min-height: 100vh; min-height: 100dvh;
}
.tab-page {
  display: none; padding: 16px;
  animation: fadeIn 0.25s ease;
}
.tab-page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Pull to Refresh */
.ptr-indicator {
  text-align: center; padding: 12px;
  color: var(--text-muted); font-size: 13px;
  display: none;
}
.ptr-indicator.visible { display: block; }
.ptr-spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  transition: background 0.2s;
}
.card:active { background: var(--card-hover); }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--accent-light); }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-change { font-size: 11px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Status Dots */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px; flex-shrink: 0;
}
.status-dot.green { background: var(--success); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.status-dot.yellow { background: var(--warning); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.status-dot.red { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.status-dot.blue { background: var(--info); box-shadow: 0 0 6px rgba(59,130,246,0.4); }
.status-dot.gray { background: var(--text-muted); }

/* List Items */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: var(--tap-min);
}
.list-item:first-child { border-radius: 12px 12px 0 0; }
.list-item:last-child { border-radius: 0 0 12px 12px; border-bottom: none; }
.list-item:only-child { border-radius: 12px; }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-desc { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.list-group { margin-bottom: 16px; }
.list-group-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 0 4px; margin-bottom: 8px; }

/* Priority badges */
.priority { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.priority.p0 { background: rgba(239,68,68,0.15); color: var(--danger); }
.priority.p1 { background: rgba(245,158,11,0.15); color: var(--warning); }
.priority.p2 { background: rgba(234,179,8,0.15); color: #eab308; }
.priority.p3 { background: rgba(34,197,94,0.15); color: var(--success); }

/* Status badges */
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.badge.active { background: rgba(34,197,94,0.15); color: var(--success); }
.badge.idle { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge.offline { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge.draft { background: rgba(99,102,241,0.15); color: var(--accent-light); }
.badge.review { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge.signed { background: rgba(34,197,94,0.15); color: var(--success); }
.badge.expired { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Section */
.section-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.section-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }

/* Quick Actions */
.action-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.action-btn {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-secondary);
  cursor: pointer; min-height: var(--tap-min);
}
.action-btn:active { background: var(--card-hover); }
.action-btn .icon { font-size: 22px; }

/* Agent Grid */
.agent-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.agent-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; text-align: center;
}
.agent-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  margin: 0 auto 8px;
}
.agent-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.agent-role { font-size: 12px; color: var(--text-secondary); }
.agent-status { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.agent-task { font-size: 11px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-chat-btn {
  margin-top: 8px; padding: 6px 12px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  min-height: var(--tap-min); width: 100%;
}

/* Department Selector */
.dept-selector {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 0 0 12px; margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dept-selector::-webkit-scrollbar { display: none; }
.dept-chip {
  flex-shrink: 0; padding: 8px 16px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
  min-height: var(--tap-min); display: flex; align-items: center;
}
.dept-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Progress Bar */
.progress-bar { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.3s; }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* Bottom Tab Bar */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--text-muted);
  font-size: 10px; font-weight: 500; cursor: pointer;
  min-height: var(--tap-min); position: relative;
  transition: color 0.2s;
}
.tab-btn.active { color: var(--accent-light); }
.tab-btn .tab-icon { font-size: 22px; line-height: 1; }
.tab-btn .tab-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 4px; border-radius: 8px; min-width: 14px; text-align: center;
}

/* Chat FAB */
.chat-fab {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  right: 16px; z-index: 90;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none; color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
  transition: transform 0.2s;
}
.chat-fab:active { transform: scale(0.92); }

/* Chat Overlay */
.chat-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: none; flex-direction: column;
}
.chat-overlay.open { display: flex; }
.chat-header {
  height: var(--header-height); padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.chat-close { background: none; border: none; color: var(--text); font-size: 24px; cursor: pointer; min-width: var(--tap-min); min-height: var(--tap-min); display: flex; align-items: center; justify-content: center; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-bubble {
  max-width: 80%; padding: 10px 14px;
  border-radius: 16px; font-size: 14px; line-height: 1.4;
  word-wrap: break-word;
}
.chat-bubble.agent { background: var(--card); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-bubble.user { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.chat-input-area {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
  padding-bottom: calc(12px + var(--safe-bottom));
}
.chat-input {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 10px 16px;
  color: var(--text); font-size: 15px; outline: none;
  min-height: var(--tap-min);
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-send {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Compliance checklist */
.check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.check-box {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.check-box.checked { background: var(--success); border-color: var(--success); color: #fff; }

/* Permission matrix */
.matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.matrix th, .matrix td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--border); }
.matrix th { color: var(--text-muted); font-weight: 600; position: sticky; top: 0; background: var(--bg); }
.matrix td:first-child { text-align: left; font-weight: 500; }

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent-light); }
.fw-600 { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Responsive */
@media (min-width: 480px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .agent-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .action-grid { grid-template-columns: repeat(4, 1fr); }
  .app-content { max-width: 600px; margin: 0 auto; }
}
