/* -------------------------------------------------------------------------- */
/*                                  Layout                                     */
/* -------------------------------------------------------------------------- */

#dashboard {
  --dashboard-bg: #f3f4f6;
  --card-bg: #ffffff;
  --surface: #ffffff;
  --muted: #5c6670;
  --text: #111827;
  --accent: #0b76ef;
  --divider: #d6dde4;
  --divider-thickness: 6px;

  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--dashboard-bg);
  overflow: hidden;
}

#dashboard .dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  width: 100%;
  height: 100%;
}

#dashboard .widget {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
  min-width: 0;
}

#dashboard .widget-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0 0.75rem;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
  box-shadow: 0 4px 10px rgba(2, 6, 23, 0.25);
}

#dashboard .widget-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-title-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 6px 18px rgba(11, 118, 239, 0.18);
}

.widget-title-button-ghost {
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
}

.widget-title-button:hover {
  transform: translateY(-2px) scale(1.03);
}

.widget-title-button:focus-visible {
  outline: 2px solid rgba(11, 118, 239, 0.3);
  outline-offset: 2px;
}

#dashboard .widget-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  color: var(--muted);
}

#widget-1,
#widget-3 {
  border-right: var(--divider-thickness) solid var(--divider);
}

#widget-1,
#widget-2 {
  border-bottom: var(--divider-thickness) solid var(--divider);
}

@media (max-width: 900px) {
  :root {
    --divider-thickness: 4px;
  }

  #dashboard .widget-title {
    height: 44px;
    flex: 0 0 44px;
    padding: 0 0.6rem;
  }
}

/* -------------------------------------------------------------------------- */
/*                              Shared UI elements                             */
/* -------------------------------------------------------------------------- */

.loading {
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

.btn-loadmore {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease;
}

.btn-loadmore:hover {
  background: rgba(11, 118, 239, 0.06);
}

.btn-edit,
.btn-delete {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-edit:hover {
  background: rgba(11, 118, 239, 0.08);
}

.btn-delete {
  background: #fff6f6;
  border-color: rgba(255, 0, 0, 0.12);
}

.btn-delete:hover {
  background: #ffecec;
}

.appointments-controls,
.activities-controls,
.news-controls {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* -------------------------------------------------------------------------- */
/*                             Terminübersicht (1)                             */
/* -------------------------------------------------------------------------- */

.appointments {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#nextAppointmentsList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.appointment-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid rgba(16, 24, 32, 0.06);
  font-size: 0.95rem;
  color: var(--text);
  min-width: 0;
}

.appointment-item:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(249, 250, 251, 0.95)
  );
}

.appointment-item::before {
  content: "\25CF";
  color: var(--accent);
  font-size: 0.65rem;
}

.appointment-item.current {
  border: 2px solid #2ecc71;
  box-shadow: 0 2px 6px rgba(46, 204, 113, 0.12);
}

.appt-date {
  font-weight: 600;
  color: var(--muted);
}

.appt-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appt-actions {
  display: flex;
  gap: 0.45rem;
  margin-left: auto;
}

.appointment-item.dienst-item .appt-actions {
  gap: 0;
}

.dienst-badge {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(11, 118, 239, 0.08);
}

/* -------------------------------------------------------------------------- */
/*                            Letzte Aktivitäten (2)                           */
/* -------------------------------------------------------------------------- */

#recentActivitiesList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.5rem;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.9),
    rgba(0, 0, 0, 0.02)
  );
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.activity-item.activity-new {
  border-left: 4px solid #2e7d32;
}

.activity-item.activity-updated {
  border-left: 4px solid #1565c0;
}

.activity-item.activity-deleted {
  border-left: 4px solid #c62828;
}

.activity-icon {
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.activity-content {
  flex: 1 1 auto;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  min-width: 0;
}

.activity-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.activity-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f1f1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-date {
  font-size: 0.8rem;
  color: #6c6c6c;
}

.activity-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: 0.75rem;
  color: #7a7a7a;
}

/* -------------------------------------------------------------------------- */
/*                              Schwarzes Brett (4)                            */
/* -------------------------------------------------------------------------- */

.news-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.bookmark-toggle,
.bookmark-icon {
  border: none;
  background: transparent;
  padding: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bookmark-icon svg,
.bookmark-toggle svg {
  width: 18px;
  height: 18px;
}

.bookmark-icon.active svg path,
.bookmark-toggle.active svg path {
  fill: orange;
}

#newsList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.news-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid rgba(16, 24, 32, 0.05);
  box-shadow: 0 1px 3px rgba(16, 24, 32, 0.04);
}

.news-item .activity-content {
  flex-direction: column;
}

.news-item .activity-title {
  font-size: 0.95rem;
}

.news-item .activity-date {
  white-space: normal;
  font-size: 0.85rem;
  line-height: 1.3;
}
/* Show only first 5 lines in news list and truncate with ellipsis */
.news-item .activity-date {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: calc(1.3em * 5);
}

.news-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* -------------------------------------------------------------------------- */
/*                                  Tasks (3)                                  */
/* -------------------------------------------------------------------------- */

.tasks-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.tasks-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  color: #1f2937;
  background: rgba(0, 0, 0, 0.03);
}

.tasks-table td {
  vertical-align: top;
  padding: 0.75rem;
}

.open-cell {
  background: rgba(255, 235, 238, 0.8);
}

.done-cell {
  background: rgba(237, 247, 237, 0.9);
}

.tasks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.task-item.task-open {
  border-left: 4px solid #f39c12;
}

.task-item.task-done {
  border-left: 4px solid #2ecc71;
}

.task-date {
  font-size: 0.85rem;
  color: var(--muted);
}

/* -------------------------------------------------------------------------- */
/*                                 News modal                                  */
/* -------------------------------------------------------------------------- */

.news-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.news-modal-box {
  width: 520px;
  max-width: 92%;
  height: 80vh;
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.news-modal-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}

.news-modal-field {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: inherit;
  font-size: 0.95rem;
  box-sizing: border-box;
}

/* Make the remarks textarea take remaining space in the modal */
.news-modal-field-remarks {
  flex: 1 1 auto;
  min-height: 0; /* allow flex to shrink properly inside overflow:auto container */
  height: auto;
  resize: none;
  display: block;
}

/* Keep title and link at their intrinsic sizes */
.news-modal-field-title,
.news-modal-field-link {
  flex: 0 0 auto;
}

.news-modal-btnrow {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.news-modal-btn {
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
}

.news-modal-btn-save {
  background: var(--accent);
  color: #fff;
}

.news-modal-btn-cancel {
  background: #e0e0e0;
}
