/* =============================================
   KNOWTHEM — DESIGN SYSTEM
   Core tokens, typography, components
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =============================================
   CSS CUSTOM PROPERTIES (TOKENS)
   ============================================= */
:root {
  /* Colors — Light Theme */
  --bg-primary:    #F7F9F8;
  --bg-secondary:  #EAF2EC;
  --bg-sidebar:    #FFFFFF;
  --bg-card:       #FFFFFF;

  --text-primary:  #1D1D1F;
  --text-secondary:#6B7280;
  --text-muted:    #9CA3AF;

  --accent:        #4F6F52;
  --accent-mid:    #7A9A7D;
  --accent-soft:   #EAF2EC;
  --accent-hover:  #3d5740;

  --success:       #3FA34D;
  --warning:       #F4A261;
  --danger:        #E76F51;

  --border:        #E5E7EB;
  --border-focus:  #7A9A7D;

  /* Shadows */
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.03), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-md:     0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg:     0 4px 6px rgba(0,0,0,0.04), 0 10px 30px rgba(0,0,0,0.08);
  --shadow-focus:  0 0 0 4px rgba(115,144,114,0.14);

  /* Border Radii */
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     24px;
  --radius-input:  16px;
  --radius-pill:   999px;

  /* Spacing */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px; --sp-16: 64px;

  /* Typography */
  --font: 'Inter', sans-serif;
  --text-xs:  12px; --text-sm: 14px; --text-base: 16px;
  --text-lg:  18px; --text-xl: 22px; --text-2xl: 28px; --text-3xl: 36px;

  /* Layout */
  --sidebar-w: 260px;
  --right-panel-w: 320px;
  --nav-h-mobile: 68px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms; --dur-base: 220ms; --dur-slow: 300ms;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* =============================================
   TYPOGRAPHY
   ============================================= */
h1 { font-size: var(--text-3xl); font-weight: 700; line-height: 1.2; }
h2 { font-size: var(--text-2xl); font-weight: 700; line-height: 1.3; }
h3 { font-size: var(--text-xl);  font-weight: 600; line-height: 1.4; }
h4 { font-size: var(--text-lg);  font-weight: 600; line-height: 1.4; }
p  { font-size: var(--text-base); color: var(--text-secondary); }

.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-muted  { color: var(--text-muted);   }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* =============================================
   LAYOUT UTILITIES
   ============================================= */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-base) var(--ease),
              background var(--dur-base) var(--ease);
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #d4613d; transform: translateY(-1px); }

.btn-sm { padding: 6px 14px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); border-radius: 18px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn-icon:active { transform: scale(0.95); }

/* =============================================
   INPUTS
   ============================================= */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.input-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-size: var(--text-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease);
  outline: none;
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.input-icon-wrap {
  position: relative;
}
.input-icon-wrap .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon-wrap .input { padding-left: 42px; }

textarea.input { resize: vertical; min-height: 100px; }

/* =============================================
   CARDS
   ============================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
  transition: transform var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-sm { border-radius: var(--radius-md); padding: var(--sp-4); }

/* =============================================
   AVATAR
   ============================================= */
.avatar {
  border-radius: var(--radius-pill);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.avatar-xs  { width: 28px;  height: 28px;  font-size: 11px; }
.avatar-sm  { width: 36px;  height: 36px;  font-size: 13px; }
.avatar-md  { width: 48px;  height: 48px;  font-size: 16px; }
.avatar-lg  { width: 64px;  height: 64px;  font-size: 22px; }
.avatar-xl  { width: 96px;  height: 96px;  font-size: 32px; }
.avatar-2xl { width: 120px; height: 120px; font-size: 40px; }

.avatar-initials {
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* =============================================
   TAGS / PILLS
   ============================================= */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
}
.tag-sm { padding: 2px 8px; font-size: 10px; }
.tag-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  pointer-events: all;
  animation: toast-in var(--dur-slow) var(--ease) forwards;
}
.toast.toast-error   { border-left-color: var(--danger);  }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-success { border-left-color: var(--success); }
.toast-out { animation: toast-out var(--dur-base) var(--ease) forwards; }

.toast-title   { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* =============================================
   SKELETON LOADERS
   ============================================= */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, #eef0ec 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* =============================================
   MODAL
   ============================================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  animation: fade-in var(--dur-base) var(--ease);
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in var(--dur-slow) var(--ease);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-body   { padding: var(--sp-6); }
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--sp-3);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade-in {
  from { opacity: 0; } to { opacity: 1; }
}

/* =============================================
   BADGE
   ============================================= */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.badge-warning { background: var(--warning); }
.badge-danger  { background: var(--danger);  }

/* =============================================
   DIVIDER
   ============================================= */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-4) 0;
}

/* =============================================
   STAT CARD
   ============================================= */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }
.stat-delta { font-size: var(--text-xs); font-weight: 500; color: var(--success); margin-top: 4px; }
.stat-delta.negative { color: var(--danger); }

/* =============================================
   SECTION HEADER
   ============================================= */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.section-title { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); }
.section-link  { font-size: var(--text-sm); color: var(--accent); font-weight: 500; cursor: pointer; }
.section-link:hover { text-decoration: underline; }

/* =============================================
   TABS
   ============================================= */
.tabs { display: flex; gap: var(--sp-1); background: var(--bg-secondary); border-radius: var(--radius-pill); padding: 4px; }
.tab {
  padding: 6px 16px; border-radius: var(--radius-pill);
  font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease);
  border: none; background: transparent;
}
.tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); font-weight: 600; }

/* =============================================
   TABLE
   ============================================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast) var(--ease);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }
tbody td { padding: 14px 16px; font-size: var(--text-sm); }

/* =============================================
   SEARCH BAR
   ============================================= */
.search-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  transition: all var(--dur-base) var(--ease);
}
.search-bar:focus-within {
  background: var(--bg-card);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.search-bar input {
  border: none; background: transparent; outline: none;
  font-size: var(--text-sm); color: var(--text-primary); flex: 1;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar .icon { color: var(--text-muted); flex-shrink: 0; }

/* =============================================
   PERSON CARD (GRID)
   ============================================= */
.person-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  cursor: pointer;
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
  position: relative;
}
.person-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.person-card .person-actions {
  position: absolute; top: 12px; right: 12px;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease);
}
.person-card:hover .person-actions { opacity: 1; }

/* =============================================
   INTERACTION ITEM
   ============================================= */
.interaction-item {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.interaction-item:last-child { border-bottom: none; }
.interaction-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* =============================================
   REMINDER ITEM
   ============================================= */
.reminder-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease);
  cursor: pointer;
}
.reminder-item:hover { background: var(--bg-secondary); }

/* =============================================
   PAGE TRANSITIONS
   ============================================= */
.page-enter {
  animation: page-fade-in var(--dur-slow) var(--ease);
}
@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =============================================
   UTILITY
   ============================================= */
.hidden   { display: none !important; }
.invisible{ visibility: hidden; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.mt-1{margin-top:var(--sp-1);}.mt-2{margin-top:var(--sp-2);}.mt-3{margin-top:var(--sp-3);}.mt-4{margin-top:var(--sp-4);}.mt-6{margin-top:var(--sp-6);}
.mb-1{margin-bottom:var(--sp-1);}.mb-2{margin-bottom:var(--sp-2);}.mb-3{margin-bottom:var(--sp-3);}.mb-4{margin-bottom:var(--sp-4);}.mb-6{margin-bottom:var(--sp-6);}
.p-3{padding:var(--sp-3);}.p-4{padding:var(--sp-4);}.p-6{padding:var(--sp-6);}
.rounded-full{border-radius:var(--radius-pill);}.rounded-lg{border-radius:var(--radius-lg);}.rounded-md{border-radius:var(--radius-md);}

/* =============================================
   LOGO ANIMATIONS
   ============================================= */
@keyframes kt-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes kt-dash {
  to { stroke-dashoffset: 0; }
}
@keyframes kt-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.logo-animate-pulse:hover .kt-node {
  animation: kt-pulse 1.5s infinite ease-in-out;
}
.logo-animate-draw .kt-stem {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: kt-dash 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.logo-animate-draw .kt-node {
  opacity: 0;
  animation: kt-fade-in 0.5s ease forwards;
}
.logo-animate-draw .kt-node:nth-of-type(1) { animation-delay: 0.1s; }
.logo-animate-draw .kt-node:nth-of-type(2) { animation-delay: 0.3s; }
.logo-animate-draw .kt-node:nth-of-type(3) { animation-delay: 0.5s; }
.logo-animate-draw .kt-node:nth-of-type(4) { animation-delay: 0.7s; }
.logo-animate-draw .kt-node:nth-of-type(5) { animation-delay: 0.9s; }
