/**
 * CallSync Manager — Global App Styles
 * Supplements Tailwind with custom component styles not easily expressed as utilities.
 */

/* ── Base ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body { font-family: 'Inter', ui-sans-serif, system-ui; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.nav-active {
  background: linear-gradient(90deg, rgba(99,102,241,.12) 0%, rgba(99,102,241,.02) 100%);
  border-left: 3px solid #6366f1;
  padding-left: calc(0.75rem - 3px);
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 0.875rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.dark .card {
  background: #111827;
  border-color: #1f2937;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.dark .card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.5); }

/* ── Stat Card ──────────────────────────────────────────────────────────────── */
.stat-card { transition: transform .2s ease, box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-2px); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7280;
  padding: 10px 16px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.dark .data-table thead th {
  background: #111827;
  color: #6b7280;
  border-color: #1f2937;
}
.data-table thead th:hover { color: #374151; background: #f3f4f6; }
.dark .data-table thead th:hover { color: #d1d5db; background: #1f2937; }
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13.5px;
  color: #374151;
  vertical-align: middle;
}
.dark .data-table tbody td {
  border-color: #1f2937;
  color: #d1d5db;
}
.data-table tbody tr { transition: background .1s ease; }
.data-table tbody tr:hover td { background: #f8fafc; }
.dark .data-table tbody tr:hover td { background: #1a2234; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Sort indicator */
.sort-asc::after  { content: ' ↑'; color: #6366f1; font-size: 10px; }
.sort-desc::after { content: ' ↓'; color: #6366f1; font-size: 10px; }

/* ── Form Controls ──────────────────────────────────────────────────────────── */
.form-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 13.5px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background-color: white;
  color: #111827;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none !important;
  -moz-appearance: none !important;
  -webkit-appearance: none !important;
}
.dark .form-input {
  background-color: #1f2937;
  border-color: #374151;
  color: #f3f4f6;
}
.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-input::placeholder { color: #9ca3af; }
select.form-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat !important; background-position: right 8px center !important; background-size: 16px !important; padding-right: 32px !important; cursor: pointer; appearance: none !important; -moz-appearance: none !important; -webkit-appearance: none !important; }
.dark select.form-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat !important; background-position: right 8px center !important; background-size: 16px !important; padding-right: 32px !important; appearance: none !important; -moz-appearance: none !important; -webkit-appearance: none !important; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; cursor: pointer; border: none; transition: all .15s ease; outline: none; line-height: 1; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; gap: 4px; }
.btn-primary { background: #6366f1; color: white; }
.btn-primary:hover { background: #4f46e5; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-secondary { background: #f3f4f6; color: #374151; }
.dark .btn-secondary { background: #1f2937; color: #d1d5db; }
.btn-secondary:hover { background: #e5e7eb; }
.dark .btn-secondary:hover { background: #374151; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.btn-ghost { background: transparent; color: #6b7280; }
.btn-ghost:hover { background: #f3f4f6; color: #111827; }
.dark .btn-ghost { color: #9ca3af; }
.dark .btn-ghost:hover { background: #1f2937; color: #f3f4f6; }
.btn-outline { background: transparent; color: #6366f1; border: 1px solid #6366f1; }
.btn-outline:hover { background: rgba(99,102,241,.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 600; }
.badge-success { background: rgba(16,185,129,.1); color: #059669; }
.dark .badge-success { color: #34d399; }
.badge-danger  { background: rgba(239,68,68,.1);  color: #dc2626; }
.dark .badge-danger  { color: #f87171; }
.badge-warning { background: rgba(245,158,11,.1); color: #d97706; }
.dark .badge-warning { color: #fbbf24; }
.badge-info    { background: rgba(59,130,246,.1);  color: #2563eb; }
.dark .badge-info    { color: #60a5fa; }
.badge-gray    { background: rgba(107,114,128,.1); color: #4b5563; }
.dark .badge-gray    { color: #9ca3af; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid #e5e7eb;
  background: white; color: #374151;
  cursor: pointer; transition: all .15s;
}
.dark .page-btn { background: #1f2937; border-color: #374151; color: #d1d5db; }
.page-btn:hover:not(:disabled) { border-color: #6366f1; color: #6366f1; }
.page-btn.active { background: #6366f1; border-color: #6366f1; color: white; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Filter Tags ────────────────────────────────────────────────────────────── */
.filter-tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 10px; border-radius: 9999px; font-size: 12px; font-weight: 500; background: rgba(99,102,241,.1); color: #6366f1; cursor: pointer; }
.filter-tag:hover { background: rgba(99,102,241,.2); }

/* ── Charts ─────────────────────────────────────────────────────────────────── */
.chart-wrapper { position: relative; }
canvas { max-width: 100%; }

/* ── Skeleton Loader ────────────────────────────────────────────────────────── */
.skeleton-box { border-radius: 6px; background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.dark .skeleton-box { background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%); background-size: 200% 100%; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Empty State ────────────────────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; text-align: center; color: #9ca3af; }
.empty-state-icon { width: 48px; height: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 600; color: #6b7280; margin-bottom: 6px; }
.dark .empty-state-title { color: #9ca3af; }

/* ── Tooltip ────────────────────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: 4px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: #111827; color: white; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 100; }
[data-tooltip]:hover::after { opacity: 1; }

/* ── Responsive Table Wrapper ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
