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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --radius-sm: 4px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-50);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* === Knoppen === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--gray-200);
}

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--gray-100);
}

.btn-danger {
  background-color: var(--danger);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
}

.btn-success {
  background-color: var(--success);
  color: var(--white);
}

.btn-success:hover:not(:disabled) {
  background-color: #15803d;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  padding: 6px 10px;
}

/* === Formulierelementen === */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 14px;
  color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* === Foutmelding === */
.error-message {
  background-color: var(--danger-light);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

.success-message {
  background-color: var(--success-light);
  color: var(--success);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

/* === Login Pagina === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--gray-100) 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-header p {
  color: var(--gray-500);
  font-size: 14px;
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--gray-400);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.login-divider span {
  padding: 0 16px;
}

/* === App Header === */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
}

.header-title a {
  color: var(--primary);
  text-decoration: none;
}

.header-nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  color: var(--gray-600);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.nav-link:hover {
  background-color: var(--gray-100);
  color: var(--gray-800);
}

.nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary);
}

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

.user-info {
  font-size: 14px;
  color: var(--gray-600);
}

/* === App Content === */
.app-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* === Dashboard === */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.playbook-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.playbook-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.playbook-card.can-edit {
  border-color: var(--success);
}

.playbook-card.read-only {
  border-color: var(--gray-300);
}

.playbook-card h3 {
  font-size: 17px;
  margin-bottom: 12px;
  color: var(--gray-800);
}

.playbook-card .card-meta {
  font-size: 13px;
  color: var(--gray-500);
}

.playbook-card .card-meta span {
  display: block;
  margin-top: 4px;
}

.playbook-card .card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
}

.card-badge.edit {
  background-color: var(--success-light);
  color: var(--success);
}

.card-badge.view {
  background-color: var(--gray-100);
  color: var(--gray-500);
}

/* === Draaiboek Detail === */
.playbook-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}

.playbook-sidebar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 0;
  position: sticky;
  top: 80px;
}

.playbook-sidebar h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  padding: 0 16px;
  margin-bottom: 8px;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li {
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  color: var(--gray-600);
}

.sidebar-nav li:hover {
  background-color: var(--gray-50);
  color: var(--gray-800);
}

.sidebar-nav li.active {
  background-color: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.playbook-main {
  min-width: 0;
}

.playbook-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.playbook-header h2 {
  font-size: 24px;
}

.back-link {
  font-size: 14px;
  color: var(--gray-500);
  cursor: pointer;
}

.back-link:hover {
  color: var(--primary);
}

/* === Secties === */
.section-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.section-header h3 {
  font-size: 16px;
  color: var(--gray-800);
}

.section-description {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

.section-body {
  padding: 20px;
}

.section-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background-color: var(--gray-50);
}

.section-empty {
  color: var(--gray-400);
  font-style: italic;
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

/* === Tabel Editor === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  background-color: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 13px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table td[contenteditable="true"] {
  background-color: var(--primary-light);
  outline: none;
  min-width: 80px;
}

.data-table td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.table-actions {
  white-space: nowrap;
}

/* === Checklist Editor === */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}

.checklist-item:last-child {
  border-bottom: none;
}

.checklist-item .item-content {
  flex: 1;
}

.checklist-item .item-content[contenteditable="true"] {
  background-color: var(--primary-light);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  outline: none;
}

.checklist-item .item-priority {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.priority-hoog {
  background-color: var(--danger-light);
  color: var(--danger);
}

.priority-normaal {
  background-color: var(--primary-light);
  color: var(--primary);
}

.priority-laag {
  background-color: var(--gray-100);
  color: var(--gray-500);
}

/* === Richtext Editor === */
.richtext-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--gray-200);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background-color: var(--gray-50);
}

.richtext-toolbar button {
  padding: 6px 10px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-600);
  transition: all 0.15s;
}

.richtext-toolbar button:hover {
  background-color: var(--gray-100);
  color: var(--gray-800);
}

.richtext-editor {
  min-height: 150px;
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  outline: none;
  line-height: 1.6;
}

.richtext-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.richtext-editor ul,
.richtext-editor ol {
  margin-left: 20px;
}

/* === FAQ Editor === */
.faq-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-question {
  padding: 12px 16px;
  font-weight: 600;
  background-color: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-answer {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
}

.faq-question[contenteditable="true"],
.faq-answer[contenteditable="true"] {
  background-color: var(--primary-light);
  outline: none;
}

/* === Links Editor === */
.link-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.link-item:last-child {
  border-bottom: none;
}

.link-item .link-info {
  flex: 1;
}

.link-item .link-title {
  font-weight: 500;
  color: var(--primary);
}

.link-item .link-url {
  font-size: 13px;
  color: var(--gray-500);
  word-break: break-all;
}

.link-item .link-description {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 4px;
}

/* === Audit Log === */
.audit-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: end;
}

.audit-filters .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.audit-table th {
  text-align: left;
  padding: 12px 16px;
  background-color: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 13px;
}

.audit-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

.audit-table tr:hover {
  background-color: var(--gray-50);
}

/* === Gebruikersbeheer === */
.users-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.user-table th {
  text-align: left;
  padding: 12px 16px;
  background-color: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 13px;
}

.user-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

.role-admin {
  background-color: var(--danger-light);
  color: var(--danger);
}

.role-editor {
  background-color: var(--primary-light);
  color: var(--primary);
}

.role-viewer {
  background-color: var(--gray-100);
  color: var(--gray-500);
}

/* === Modaal === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal h3 {
  margin-bottom: 20px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* === Toast Meldingen === */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast.success {
  background-color: var(--success);
  color: var(--white);
}

.toast.error {
  background-color: var(--danger);
  color: var(--white);
}

.toast.info {
  background-color: var(--primary);
  color: var(--white);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Laadstatus === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Responsive === */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .playbook-layout {
    grid-template-columns: 1fr;
  }
  .playbook-sidebar {
    position: static;
  }
}

@media (max-width: 600px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    padding: 0 12px;
    flex-wrap: wrap;
    height: auto;
    padding-top: 8px;
    padding-bottom: 8px;
    gap: 8px;
  }
  .header-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .audit-filters {
    flex-direction: column;
  }
}

/* === Print === */
@media print {
  .app-header,
  .playbook-sidebar,
  .section-actions,
  .btn,
  .toast-container {
    display: none !important;
  }
  .app-content {
    max-width: 100%;
    padding: 0;
  }
  .playbook-layout {
    grid-template-columns: 1fr;
  }
  .section-container {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--gray-300);
  }
  body {
    font-size: 12px;
  }
}

/* === Weekoverzicht: taken per dag === */
.week-overview {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.day-group {
  border-bottom: 1px solid var(--gray-200);
}

.day-group:last-child {
  border-bottom: none;
}

.day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.day-abbr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.day-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--gray-800);
}

.day-tasks {
  padding: 8px 12px 8px 58px;
}

.day-tasks .checklist-item {
  margin-bottom: 4px;
}

.day-empty {
  padding: 8px 0;
  color: var(--gray-400);
  font-style: italic;
  font-size: 13px;
}

@media (max-width: 768px) {
  .day-tasks {
    padding-left: 12px;
  }
}

@media print {
  .day-header {
    background: none;
    border-bottom: 2px solid var(--gray-700);
  }
  .day-abbr {
    background: var(--gray-700);
  }
  .youtube-embed-container {
    display: none !important;
  }
  .item-media-gallery {
    break-inside: avoid;
  }
}

/* === Media Gallery (weergave) === */
.item-media-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}

.media-thumbnail-link {
  display: block;
}

.media-thumbnail {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--gray-200);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.media-thumbnail:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}

.media-video-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s;
}

.media-video-link:hover {
  background: var(--gray-200);
  text-decoration: none;
}

.media-video-icon {
  font-size: 16px;
}

.media-video-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.youtube-embed-container {
  position: relative;
  width: 280px;
  padding-bottom: 157.5px; /* 16:9 ratio for 280px width */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.youtube-embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* === Media Editor === */
.checklist-item-editor {
  flex-direction: column;
  align-items: stretch;
}

.checklist-item-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.btn-add-media {
  position: relative;
  font-size: 16px !important;
  line-height: 1;
}

.media-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  background: var(--primary);
  color: var(--white);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
}

.editor-media-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-left: 0;
}

.editor-media-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
}

.editor-media-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.editor-media-video-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 24px;
}

.editor-media-label {
  font-size: 11px;
  color: var(--gray-500);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-top: 2px;
}

.btn-remove-media {
  position: absolute;
  top: -6px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--white);
  border: 2px solid var(--white);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-remove-media:hover {
  background: #b91c1c;
}

/* === Responsive media === */
@media (max-width: 600px) {
  .item-media-gallery {
    flex-direction: column;
  }
  .youtube-embed-container {
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
  }
  .media-thumbnail {
    width: 80px;
    height: 80px;
  }
}
