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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f5f2e8;
}

/* === App Shell =============================================================== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* === Header ================================================================= */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #1e3a5f;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.app-subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  margin-left: 4px;
}

/* === Buttons ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: #355e3b; color: white; }
.btn-primary:hover { background: #2a4c30; }

.btn-ghost {
  background: rgba(255,255,255,0.13);
  color: white;
  border: 1px solid rgba(255,255,255,0.22);
}
.btn-ghost:hover { background: rgba(255,255,255,0.22); }

.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Inside modals / panels the ghost needs different colours */
.modal .btn-ghost,
.panel .btn-ghost {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}
.modal .btn-ghost:hover,
.panel .btn-ghost:hover { background: #e5e7eb; }

/* === Board ================================================================== */
.board-wrapper {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px;
}

.board {
  display: flex;
  gap: 16px;
  height: 100%;
  min-width: max-content;
  align-items: flex-start;
}

/* === Kanban Column ========================================================== */
.column {
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 280px;
  background: #ebe8df;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
  max-height: calc(100vh - 100px);
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 3px solid;
  flex-shrink: 0;
}

.column-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.column-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a2e;
}

.column-count {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background: rgba(0,0,0,0.07);
  padding: 1px 7px;
  border-radius: 10px;
}

.column-add-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
  flex-shrink: 0;
}
.column-add-btn:hover { background: rgba(0,0,0,0.09); color: #374151; }

.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  transition: background 0.15s;
}
.column-cards.drag-over { background: rgba(53,94,59,0.07); }

/* === Kanban Card ============================================================ */
.card {
  background: white;
  border-radius: 8px;
  padding: 12px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.05);
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.card.dragging { opacity: 0.45; cursor: grabbing; }

.card-contacts {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.contact-chip {
  display: inline-flex;
  align-items: center;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-chip.chip-2 { background: #fdf4ff; color: #7e22ce; }

.contact-sep { color: #9ca3af; font-size: 11px; font-weight: 700; }

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  line-height: 1.4;
  margin-bottom: 4px;
}

.card-context {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-empty-contacts {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
  margin-bottom: 6px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f3f4f6;
}

.card-date { font-size: 11px; color: #9ca3af; }

.card-edit-btn {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
  font-family: inherit;
}
.card-edit-btn:hover { background: #f3f4f6; color: #374151; }

/* === Modal ================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 600; color: #111827; }

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 20px;
  color: #9ca3af;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}
.modal-close:hover { background: #f3f4f6; color: #374151; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.modal-footer-right { display: flex; gap: 8px; }

/* === Contacts Side Panel ==================================================== */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 90;
  display: flex;
  justify-content: flex-end;
}

.panel {
  background: white;
  width: 380px;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: #1e3a5f;
  color: white;
  flex-shrink: 0;
}

.panel-title { font-size: 16px; font-weight: 600; }

.panel-header .modal-close { color: rgba(255,255,255,0.65); }
.panel-header .modal-close:hover { background: rgba(255,255,255,0.12); color: white; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-toolbar { display: flex; justify-content: flex-end; }

/* === Contacts List ========================================================== */
.contacts-list { display: flex; flex-direction: column; gap: 8px; }

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
}

.contact-info { flex: 1; min-width: 0; }

.contact-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-meta {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-edit-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s;
  flex-shrink: 0;
}
.contact-edit-btn:hover { background: #e5e7eb; color: #374151; }

.contacts-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  padding: 32px 0;
  line-height: 1.6;
}

/* === Form Elements ========================================================== */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  letter-spacing: 0.2px;
}

.form-hint { font-weight: 400; color: #9ca3af; }
.required { color: #dc2626; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: #111827;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: #1e3a5f;
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}

.form-textarea { resize: vertical; }
.form-select { cursor: pointer; }

/* === Toast ================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e3a5f;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transition: transform 0.25s ease;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
.toast.visible  { transform: translateX(-50%) translateY(0); }
.toast.success  { background: #355e3b; }
.toast.error    { background: #dc2626; }

/* === Loading / empty states ================================================= */
.loading {
  text-align: center;
  color: #9ca3af;
  padding: 48px;
  font-size: 13px;
  width: 100%;
}

/* === Scrollbars ============================================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
