/* ============================================================
   CSS custom properties
   ============================================================ */
:root {
  --color-gray:   #e5e7eb;
  --color-blue:   #bfdbfe;
  --color-yellow: #fef08a;
  --color-green:  #bbf7d0;
  --color-red:    #fecaca;
  --color-purple: #e9d5ff;

  --priority-laag:    #22c55e;
  --priority-normaal: #f97316;
  --priority-hoog:    #ef4444;

  --tap-target: 44px;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  --topbar-height: 56px;
  --admin-panel-max: 340px;
  --font: system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: #1f2937;
  background: #f3f4f6;
}

button {
  font-family: var(--font);
  font-size: 14px;
  min-height: var(--tap-target);
  min-width: var(--tap-target);
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: #fff;
  transition: background 0.15s, opacity 0.15s;
}
button:hover  { background: #f9fafb; }
button:active { opacity: 0.8; }

input, select, textarea {
  font-family: var(--font);
  font-size: 15px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3b82f6; }
textarea { resize: vertical; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.hidden  { display: none !important; }
.error   { color: #ef4444; font-size: 13px; margin-top: 4px; }
.required { color: #ef4444; }

.btn-primary {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
  font-weight: 600;
}
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #fff; }
.btn-danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
  font-weight: 600;
}
.btn-danger:hover { background: #dc2626; }

/* ============================================================
   Overlays (name, admin PIN, task modal)
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.overlay-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.overlay-box h2 {
  font-size: 20px;
  font-weight: 700;
}

.overlay-box p {
  color: #6b7280;
  font-size: 14px;
}

.overlay-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Task modal form */
.modal-form form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   Top bar
   ============================================================ */
#topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-height);
  padding: 0 14px;
  background: #1e293b;
  color: #f8fafc;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#app-title {
  font-size: 18px;
  font-weight: 700;
  margin-right: auto;
}

#user-name {
  font-size: 13px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

#topbar-actions {
  display: flex;
  gap: 8px;
}

#topbar-actions button {
  background: transparent;
  border: 1px solid #475569;
  color: #f8fafc;
  font-size: 13px;
  padding: 6px 12px;
}
#topbar-actions button:hover { background: #334155; }

/* ============================================================
   Admin panel
   ============================================================ */
#admin-panel {
  background: #1e293b;
  color: #f8fafc;
  padding: 16px 14px;
  border-bottom: 2px solid #334155;
}

#admin-panel h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 12px;
}

#admin-panel-inner {
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#admin-columns-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-col-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #334155;
  border-radius: var(--radius);
  padding: 10px 12px;
}

.admin-col-row input[type="text"],
.admin-col-row select {
  background: #1e293b;
  color: #f8fafc;
  border-color: #475569;
  width: auto;
  flex: 1 1 120px;
  min-width: 80px;
}

.admin-col-row button {
  background: #475569;
  color: #f8fafc;
  border-color: #64748b;
  min-width: unset;
  padding: 6px 10px;
  font-size: 13px;
}
.admin-col-row button:hover { background: #64748b; }
.admin-col-row .btn-danger { background: #7f1d1d; border-color: #991b1b; }
.admin-col-row .btn-danger:hover { background: #991b1b; }

#admin-add-col {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: #0f172a;
  border-radius: var(--radius);
}

.admin-domain-section {
  margin-bottom: 16px;
}

.admin-sub-cols {
  margin-left: 18px;
  border-left: 3px solid #334155;
  padding-left: 12px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-sub-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: #0f172a;
  border-radius: var(--radius);
  margin-top: 2px;
}

.admin-sub-add input[type="text"],
.admin-sub-add select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
  flex: 1 1 120px;
  min-width: 80px;
}

.admin-orphan-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 4px 0 6px;
}

.acol-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.dom-check {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.dom-check input[type="checkbox"] {
  accent-color: var(--dom-color, #3b82f6);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.dom-check span {
  background: var(--dom-color, #3b82f6);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 11px;
  opacity: 0.75;
  transition: opacity 0.15s;
}

.dom-check input:checked + span {
  opacity: 1;
}

#admin-add-col-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: #0f172a;
  border-radius: var(--radius);
}

#admin-add-col-area input[type="text"],
#admin-add-col-area select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
  flex: 1 1 120px;
  min-width: 80px;
}

#admin-add-col input,
#admin-add-col select {
  background: #1e293b;
  color: #f8fafc;
  border-color: #475569;
  width: auto;
  flex: 1 1 140px;
}

/* ============================================================
   Search bar
   ============================================================ */
#search-bar {
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

#search-input {
  width: 100%;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  background: #f9fafb;
  outline: none;
  max-width: 480px;
}
#search-input:focus {
  border-color: #3b82f6;
  background: #fff;
}

/* ============================================================
   Filter bar
   ============================================================ */
#filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.filter-group-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.filter-separator {
  width: 1px;
  height: 18px;
  background: #e5e7eb;
  margin: 0 4px;
}

.filter-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  min-height: 28px;
  min-width: unset;
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #374151;
  cursor: pointer;
  transition: opacity 0.15s;
}
.filter-chip:hover  { opacity: 0.8; background: inherit; }
.filter-chip.active { font-weight: 700; }

/* ============================================================
   Main content layout
   ============================================================ */
#main-content {
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Board view (Kanban)
   ============================================================ */
#board-view {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.column {
  flex: 0 0 calc(100vw - 52px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 100%;
  overflow: hidden;
}

.column-header {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.column-header .col-task-count {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.7;
}

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

.col-toggle {
  font-size: 11px;
  opacity: 0.7;
}

.col-body--collapsed {
  display: none !important;
}

.task-card--done {
  opacity: 0.7;
}

.task-card--done .card-title {
  text-decoration: line-through;
}

.task-card--done .card-header {
  cursor: pointer;
}

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

.column-footer {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid #f3f4f6;
}

.add-task-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed #d1d5db;
  color: #6b7280;
  font-size: 13px;
  min-height: 38px;
}
.add-task-btn:hover { background: #f9fafb; border-color: #9ca3af; color: #374151; }

.empty-col {
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

@media (min-width: 640px) {
  .column { flex: 0 0 280px; }
}

@media (min-width: 1024px) {
  #board-view { scroll-snap-type: none; }
  .column { flex: 1 1 240px; max-width: 340px; }
}

/* ============================================================
   Task cards
   ============================================================ */
.task-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid var(--priority-normaal);
  border-radius: 6px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: grab;
}
.task-card.dragging {
  opacity: 0.35;
  cursor: grabbing;
}
.column-body.drag-over {
  background: #dbeafe;
  outline: 2px dashed #3b82f6;
  outline-offset: -6px;
}

.task-card[data-priority="laag"]    { border-left-color: var(--priority-laag); }
.task-card[data-priority="normaal"] { border-left-color: var(--priority-normaal); }
.task-card[data-priority="hoog"]    { border-left-color: var(--priority-hoog); }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.card-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  word-break: break-word;
}

.card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.card-actions button {
  min-height: 32px;
  min-width: 32px;
  padding: 4px 6px;
  font-size: 13px;
  border-color: #e5e7eb;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
}

.label-badge {
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}

.priority-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.priority-dot.laag    { background: var(--priority-laag); }
.priority-dot.normaal { background: var(--priority-normaal); }
.priority-dot.hoog    { background: var(--priority-hoog); }

.due-date { font-size: 12px; }
.due-date.overdue { color: #ef4444; font-weight: 600; }

.card-description {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  padding-top: 4px;
  border-top: 1px solid #f3f4f6;
  max-height: 120px;
  overflow-y: auto;
}

.card-description a {
  color: #2563eb;
  word-break: break-all;
}

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

/* ============================================================
   Simple view
   ============================================================ */
#simple-view {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.simple-sections {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.simple-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  gap: 8px;
}

.simple-col-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.simple-section-header .section-toggle {
  font-size: 11px;
  opacity: 0.6;
}

.simple-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.simple-add-btn {
  background: rgba(255,255,255,0.3);
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  color: inherit;
  min-height: unset;
  min-width: unset;
}
.simple-add-btn:hover {
  background: rgba(255,255,255,0.5);
}

.simple-section-body {
  background: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-top: none;
}

.simple-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  min-height: var(--tap-target);
  font-size: 14px;
}
.simple-task-row:last-child { border-bottom: none; }

.simple-task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.simple-task-title {
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: break-word;
}

.simple-task-desc {
  font-size: 12px;
  color: #6b7280;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow-y: auto;
}

.simple-task-desc a {
  color: #2563eb;
  word-break: break-all;
}

.simple-task-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
  flex-shrink: 0;
}

.simple-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 14px;
  flex-shrink: 0;
  width: auto;
  opacity: 0.4;
  line-height: 1;
  min-height: unset;
  min-width: unset;
}
.simple-delete-btn:hover { opacity: 1; }

.simple-empty {
  padding: 14px;
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
}

/* ============================================================
   Attachments
   ============================================================ */
.attachment-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
}

.attachment-link {
  flex: 1;
  min-width: 0;
  color: #2563eb;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-link:hover { text-decoration: underline; }

.attachment-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  flex-shrink: 0;
  width: auto;
  opacity: 0.6;
  min-height: unset;
  min-width: unset;
}
.attachment-delete:hover { opacity: 1; }

.attachment-empty {
  font-size: 13px;
  color: #9ca3af;
  padding: 4px 0;
}

.attachment-upload {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.attachment-upload input[type="file"] {
  flex: 1;
  font-size: 13px;
  padding: 6px 8px;
  min-width: 0;
}

.attachment-count {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}

/* Thumbnail in bijlagenlijst */
.attachment-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  flex-shrink: 0;
}

.attachment-link--image {
  cursor: pointer;
  color: #2563eb;
}
.attachment-link--image:hover { text-decoration: underline; }

/* Lightbox */
#lightbox {
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

#lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  cursor: default;
}

#lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 501;
}
#lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* ============================================================
   Email drop overlay
   ============================================================ */
.email-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(59, 130, 246, 0.12);
  border: 4px dashed #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.15s;
}
.email-drop-overlay.active {
  pointer-events: all;
  background: rgba(59, 130, 246, 0.22);
}
.email-drop-overlay.hidden { display: none; }
.email-drop-inner {
  background: #fff;
  border-radius: 16px;
  padding: 48px 64px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}
.email-drop-icon { font-size: 3rem; margin-bottom: 12px; }
.email-drop-inner p { font-size: 1.2rem; color: #1e40af; font-weight: 600; margin: 0; }

.app-version {
  font-size: 0.55em;
  opacity: 0.45;
  font-weight: 400;
  vertical-align: middle;
}

/* ============================================================
   Domain badge
   ============================================================ */
.domain-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px 4px 0 0;
  background: var(--dom-color, #dbeafe);
  color: #1e3a5f;
  margin: -8px -8px 6px -8px;
  width: calc(100% + 16px);
  box-sizing: border-box;
}
.domain-badge--sm {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--dom-color, #dbeafe);
  color: #1e3a5f;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.simple-task-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 2px;
}

/* Domain filter chips */
.domain-chip {
  background: var(--dom-color, #dbeafe);
  color: #1e3a5f;
  border-color: transparent;
  font-weight: 600;
}
.domain-chip.active {
  outline: 2px solid #1e3a8a;
  outline-offset: 1px;
}
