/* ============================================================
   SignConnect — Global Styles & Design System
   main.css
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  /* Colors */
  --color-bg:           #0f1117;
  --color-bg-2:         #161b27;
  --color-bg-3:         #1e2535;
  --color-surface:      #242b3d;
  --color-surface-2:    #2d3650;
  --color-border:       rgba(255,255,255,0.08);
  --color-border-hover: rgba(255,255,255,0.16);

  --color-primary:      #4f8ef7;
  --color-primary-dark: #3a72d8;
  --color-primary-glow: rgba(79,142,247,0.25);
  --color-secondary:    #a78bfa;
  --color-accent:       #34d399;
  --color-danger:       #f87171;
  --color-warning:      #fbbf24;

  --color-text:         #e8eaf0;
  --color-text-2:       #9aa3b8;
  --color-text-3:       #5c6780;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #4f8ef7 0%, #a78bfa 100%);
  --grad-accent:  linear-gradient(135deg, #34d399 0%, #4f8ef7 100%);
  --grad-danger:  linear-gradient(135deg, #f87171 0%, #fb923c 100%);

  /* Typography */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;
  --text-5xl:  3rem;

  --fw-normal:  400;
  --fw-medium:  500;
  --fw-semibold:600;
  --fw-bold:    700;

  /* Spacing */
  --space-1: 0.25rem;  --space-2: 0.5rem;   --space-3: 0.75rem;
  --space-4: 1rem;     --space-5: 1.25rem;  --space-6: 1.5rem;
  --space-8: 2rem;     --space-10: 2.5rem;  --space-12: 3rem;
  --space-16: 4rem;    --space-20: 5rem;    --space-24: 6rem;

  /* Radii */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 24px var(--color-primary-glow);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;

  /* Z-index scale */
  --z-base:    1;
  --z-dropdown: 100;
  --z-sticky:  200;
  --z-overlay: 300;
  --z-modal:   400;
  --z-toast:   500;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }
h1,h2,h3,h4,h5,h6 { line-height: 1.3; font-weight: var(--fw-bold); }

/* ── Typography helpers ─────────────────────────────────────── */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }
.text-muted { color: var(--color-text-2); }
.text-faint { color: var(--color-text-3); }
.font-mono  { font-family: var(--font-mono); }
.font-bold  { font-weight: var(--fw-bold); }
.font-semibold { font-weight: var(--fw-semibold); }

/* ── Gradient text ──────────────────────────────────────────── */
.gradient-text {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Button system ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  transition: all var(--transition-normal);
  outline: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition-fast);
}
.btn:hover::after  { background: rgba(255,255,255,0.06); }
.btn:active::after { background: rgba(255,255,255,0.12); }

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 16px var(--color-primary-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--color-primary-glow); transform: translateY(-1px); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-border-hover); background: var(--color-surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-2);
  padding: var(--space-2) var(--space-4);
}
.btn-ghost:hover { background: var(--color-surface); color: var(--color-text); }

.btn-danger {
  background: var(--grad-danger);
  color: #fff;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--color-surface);
  color: var(--color-text-2);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
}
.btn-icon:hover { background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-border-hover); }
.btn-icon.active { background: var(--color-primary); color: #fff; border-color: transparent; }

.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }
.btn-xl { padding: var(--space-5) var(--space-10); font-size: var(--text-lg); }

/* ── Form controls ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-2);
}

.form-input {
  background: var(--color-bg-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}
.form-input::placeholder { color: var(--color-text-3); }
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}
.form-input:invalid:not(:placeholder-shown) { border-color: var(--color-danger); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239aa3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--fw-bold);
  line-height: 1;
}
.badge-primary { background: var(--color-primary); color: #fff; }
.badge-accent   { background: var(--color-accent);  color: #000; }
.badge-danger   { background: var(--color-danger);  color: #fff; }

/* ── Avatar ──────────────────────────────────────────────────── */
.avatar {
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}
.avatar-sm  { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-md  { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-lg  { width: 48px; height: 48px; font-size: var(--text-base); }
.avatar-xl  { width: 64px; height: 64px; font-size: var(--text-xl); }

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.card:hover { border-color: var(--color-border-hover); }
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-4) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--color-text-3);
  font-size: var(--text-xs);
}
.divider-text::before,.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-surface-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-3); }

/* ── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  max-width: 340px;
  pointer-events: auto;
  animation: toastIn 300ms ease forwards;
  border-left: 3px solid var(--color-primary);
}
.toast.success { border-left-color: var(--color-accent); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.out     { animation: toastOut 300ms ease forwards; }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(100%) scale(0.9); }
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--transition-fast) ease;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--color-bg-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: scaleIn var(--transition-normal) ease;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.modal-title { font-size: var(--text-xl); font-weight: var(--fw-bold); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-2);
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--color-surface); color: var(--color-text); }

/* ── Skeleton loaders ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--color-surface) 25%,
    var(--color-surface-2) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; margin-bottom: 12px; }
.skeleton-circle{ border-radius: 50%; }

/* ── Status indicator ────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-online  { background: var(--color-accent); box-shadow: 0 0 6px var(--color-accent); }
.status-away    { background: var(--color-warning); }
.status-offline { background: var(--color-text-3); }

/* ── Utility classes ─────────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.justify-center{ justify-content: center; }
.justify-between{ justify-content: space-between; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none !important; }
.visible{ visibility: visible; }
.invisible { visibility: hidden; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.inset-0  { inset: 0; }
.z-10 { z-index: 10; }
.rounded-full { border-radius: var(--radius-full); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-none { user-select: none; }
.pointer { cursor: pointer; }
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }

.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn   { from { opacity:0 } to { opacity:1 } }
@keyframes fadeOut  { from { opacity:1 } to { opacity:0 } }
@keyframes scaleIn  { from { opacity:0; transform:scale(0.9) } to { opacity:1; transform:scale(1) } }
@keyframes slideUp  { from { opacity:0; transform:translateY(16px) } to { opacity:1; transform:translateY(0) } }
@keyframes slideDown{ from { opacity:0; transform:translateY(-16px) } to { opacity:1; transform:translateY(0) } }
@keyframes slideRight{ from { opacity:0; transform:translateX(-16px) } to { opacity:1; transform:translateX(0) } }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:0.5} }
@keyframes spin     { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes bounce   {
  0%,100%{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}
  50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}
}
@keyframes wave     {
  0%,100%{ transform:rotate(0deg) }
  25%    { transform:rotate(20deg) }
  75%    { transform:rotate(-20deg) }
}

.animate-fadeIn    { animation: fadeIn var(--transition-normal) ease both; }
.animate-slideUp   { animation: slideUp var(--transition-normal) ease both; }
.animate-pulse     { animation: pulse 2s infinite; }
.animate-spin      { animation: spin 1s linear infinite; }
.animate-wave      { animation: wave 1s ease-in-out infinite; }
.animate-bounce    { animation: bounce 1s infinite; }

/* ── Responsive grid ─────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--space-6); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 640px) {
  :root { font-size: 14px; }
  .grid-4,.grid-3,.grid-2 { grid-template-columns: 1fr; }
  .container { padding: 0 var(--space-4); }
  .modal { padding: var(--space-6); border-radius: var(--radius-xl); }
  #toast-container { right: var(--space-3); bottom: var(--space-3); left: var(--space-3); }
  .toast { max-width: 100%; }
}

/* ── Focus visible polish ────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ── Selection ───────────────────────────────────────────────── */
::selection {
  background: var(--color-primary);
  color: #fff;
}

/* ── Confidence meter ────────────────────────────────────────── */
.confidence-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--color-surface-2);
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--grad-primary);
  transition: width 200ms ease;
}
