/* Keep sidebar readable and sticky */
#sidebar .sidebar {
  height: calc(100vh - 56px); /* 56px ~ navbar height */
  overflow-y: auto;
}

#sidebar .nav-link {
  border-radius: .5rem;
  margin: 2px 8px;
}

#sidebar .nav-link.active {
  font-weight: 600;
}

/* Avatar styles */
.avatar {
  object-fit: cover;
}
.avatar-initials {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0d6efd22;
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
}

.agent-editor-form .card-body {
  padding: 1.5rem;
}

.agent-form-section {
  display: grid;
  gap: 1rem;
}

.agent-section-label {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.agent-section-label .badge {
  width: 1.7rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.agent-prompt-editor {
  min-height: 18rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

.article-editor {
  min-height: 24rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.article-preview h2 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.article-preview p:last-child {
  margin-bottom: 0;
}

/* Productivity Hub */
.productivity-hero {
  background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 45%, #f3fff5 100%);
}

.view-pane {
  display: none;
}

.view-pane.active {
  display: block;
}

.calendar-grid {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #fff;
}

.calendar-dow-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

.calendar-dow {
  text-align: center;
  padding: 0.55rem 0.25rem;
  font-size: 0.78rem;
  color: #475569;
  font-weight: 600;
}

.calendar-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-cell {
  min-height: 96px;
  border: 0;
  border-right: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  text-align: left;
  padding: 0.45rem;
}

.calendar-cell:nth-child(7n) {
  border-right: 0;
}

.calendar-cell-muted {
  background: #f8fafc;
}

.calendar-cell-today {
  box-shadow: inset 0 0 0 1px #60a5fa;
}

.calendar-cell-selected {
  box-shadow: inset 0 0 0 2px #2563eb;
  background: #eff6ff;
}

.calendar-day {
  display: inline-block;
  font-weight: 600;
  color: #0f172a;
  font-size: 0.86rem;
}

.calendar-dot-wrap {
  display: block;
  margin-top: 0.25rem;
}

.calendar-dot {
  display: inline-block;
  font-size: 0.72rem;
  background: #1d4ed8;
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 580px;
  overflow-y: auto;
}

.agenda-item {
  border: 1px solid #e2e8f0;
  border-radius: 0.6rem;
  background: #fff;
  display: flex;
  width: 100%;
  text-align: left;
  padding: 0.55rem;
  gap: 0.6rem;
}

.agenda-item:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.agenda-time {
  min-width: 42px;
  color: #1e3a8a;
  font-weight: 700;
  font-size: 0.8rem;
}

.agenda-title {
  font-weight: 600;
  color: #0f172a;
}

.agenda-meta {
  font-size: 0.78rem;
  color: #64748b;
}

.contact-search {
  max-width: 520px;
}

.contact-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.7rem;
  background: #fff;
  width: 100%;
  text-align: left;
  padding: 0.8rem;
}

.contact-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.contact-name {
  font-weight: 700;
  color: #0f172a;
}

.contact-sub {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.contact-line {
  font-size: 0.84rem;
  color: #334155;
  margin-top: 0.2rem;
}

.task-col {
  border: 1px solid #e2e8f0;
  border-radius: 0.7rem;
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.task-col-head {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #0f172a;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-col-body {
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 180px;
}

.task-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.6rem;
  background: #fff;
  text-align: left;
  padding: 0.6rem;
}

.task-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.task-card-title {
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.2rem;
}

.task-card-meta {
  color: #64748b;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

.task-empty {
  color: #94a3b8;
  font-size: 0.82rem;
  padding: 0.55rem 0.25rem;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
}

.week-col {
  border-right: 1px solid #eef2f7;
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.week-col:last-child {
  border-right: 0;
}

.week-col-head {
  padding: 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  border-bottom: 1px solid #eef2f7;
  background: #f8fafc;
}

.week-col-body {
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.week-event {
  border: 1px solid #dbeafe;
  background: #eff6ff;
  border-radius: 0.55rem;
  padding: 0.4rem 0.5rem;
  text-align: left;
  color: #0f172a;
  width: 100%;
}

.week-event span {
  display: block;
  font-size: 0.75rem;
  color: #334155;
}

.day-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.day-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  border-bottom: 1px solid #eef2f7;
}

.day-hour {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  padding: 0.55rem;
  border-right: 1px solid #eef2f7;
  background: #f8fafc;
}

.day-cell {
  min-height: 48px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

@media (max-width: 1200px) {
  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-col {
    border-bottom: 1px solid #eef2f7;
    border-right: 1px solid #eef2f7;
  }
}

/* === Productivity Hub Pro Theme (2026-03-26) === */
.productivity-shell {
  --prod-bg-1: #f4f7fb;
  --prod-bg-2: #eef6ff;
  --prod-card: #ffffff;
  --prod-border: #dbe4f0;
  --prod-text: #0f172a;
  --prod-muted: #64748b;
  --prod-primary: #0f4c81;
  --prod-primary-2: #1d6fa5;
  --prod-success: #15803d;
  --prod-danger: #b91c1c;
  --prod-warning: #b45309;
  font-family: "Sarabun", "Noto Sans Thai", "Segoe UI", "Inter", sans-serif;
  color: var(--prod-text);
}

.productivity-shell .card {
  border-radius: 14px !important;
  border: 1px solid var(--prod-border) !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06) !important;
  background: var(--prod-card);
}

.productivity-hero {
  background:
    radial-gradient(1400px 320px at 8% -20%, #dbeafe 0%, transparent 60%),
    radial-gradient(1200px 300px at 100% 0%, #dcfce7 0%, transparent 50%),
    linear-gradient(145deg, var(--prod-bg-1) 0%, var(--prod-bg-2) 60%, #f8fbff 100%);
}

.productivity-hero h1 {
  letter-spacing: 0.2px;
  font-weight: 700;
}

#prod-tabs {
  gap: 0.45rem;
}

#prod-tabs .nav-link {
  border-radius: 999px;
  border: 1px solid #d9e3ef;
  background: #f8fbff;
  color: #1f2937;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
}

#prod-tabs .nav-link:hover {
  border-color: #b6c8dd;
  background: #f2f7ff;
}

#prod-tabs .nav-link.active {
  color: #fff;
  border-color: var(--prod-primary);
  background: linear-gradient(135deg, var(--prod-primary) 0%, var(--prod-primary-2) 100%);
  box-shadow: 0 8px 20px rgba(15, 76, 129, 0.25);
}

#view-calendar .btn,
#view-contacts .btn,
#view-tasks .btn,
#view-sync .btn {
  border-radius: 10px;
  font-weight: 600;
}

#view-calendar .btn-primary,
#view-contacts .btn-primary,
#view-tasks .btn-primary,
#view-sync .btn-primary {
  border-color: var(--prod-primary);
  background: linear-gradient(135deg, var(--prod-primary) 0%, var(--prod-primary-2) 100%);
}

#view-calendar .btn-outline-secondary,
#view-contacts .btn-outline-secondary,
#view-tasks .btn-outline-secondary,
#view-sync .btn-outline-secondary {
  border-color: #ced9e8;
  color: #1f2937;
  background: #fff;
}

.calendar-grid {
  border-radius: 14px;
  border: 1px solid var(--prod-border);
  overflow: hidden;
  background: #fff;
}

.calendar-dow {
  text-transform: uppercase;
  letter-spacing: .45px;
  font-size: .73rem;
  color: #475569;
  font-weight: 700;
}

.calendar-cell {
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.calendar-cell:hover {
  background: #f8fbff;
}

.calendar-cell-selected {
  box-shadow: inset 0 0 0 2px #1d4ed8;
  background: #eff6ff;
}

.calendar-day {
  font-size: 0.9rem;
  font-weight: 700;
}

.calendar-dot {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  font-weight: 700;
  min-width: 1.45rem;
  text-align: center;
}

.agenda-list {
  max-height: 640px;
}

.agenda-item {
  border-radius: 12px;
  border-color: #dde7f2;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}

.agenda-item:hover {
  transform: translateY(-1px);
  border-color: #b8d2f2;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.09);
}

.agenda-time {
  font-size: .82rem;
  color: #1e3a8a;
}

.week-col-head,
.task-col-head {
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7ff 100%);
}

.week-event {
  border: 1px solid #cfe2ff;
  background: linear-gradient(180deg, #f4f8ff 0%, #edf4ff 100%);
  transition: transform .15s ease, box-shadow .2s ease;
}

.week-event:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(29, 78, 216, 0.12);
}

.contact-card {
  border-radius: 12px;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}

.contact-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.09);
}

.task-col {
  border-radius: 12px;
}

.task-col-body {
  min-height: 260px;
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
}

.task-card {
  border-radius: 10px;
  border-color: #d8e4f5;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}

.task-card:hover {
  transform: translateY(-1px);
  border-color: #bfd4ef;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.task-card.dragging {
  opacity: 0.75;
  transform: rotate(-1deg);
}

.task-col-body.drop-over {
  outline: 2px dashed #3b82f6;
  outline-offset: -6px;
  background: #f3f8ff;
}

#event-modal .modal-content,
#contact-modal .modal-content,
#task-modal .modal-content {
  border-radius: 14px;
  border: 1px solid var(--prod-border);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
}

#event-modal .modal-header,
#contact-modal .modal-header,
#task-modal .modal-header {
  background: linear-gradient(180deg, #f8fbff 0%, #f1f7ff 100%);
  border-bottom: 1px solid var(--prod-border);
}

@media (max-width: 992px) {
  .productivity-shell .card {
    border-radius: 12px !important;
  }

  .agenda-list {
    max-height: none;
  }
}
