:root {
  --ui-font-heading: "Space Grotesk", "Segoe UI", sans-serif;
  --ui-font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --ui-bg-1: #f4f8fa;
  --ui-bg-2: #e8f3f2;
  --ui-bg-3: #fef6ee;
  --ui-surface: rgba(255, 255, 255, 0.86);
  --ui-surface-solid: #ffffff;
  --ui-border: #d7e4e8;
  --ui-text: #16323a;
  --ui-text-muted: #4a6671;
  --ui-accent: #0f766e;
  --ui-accent-strong: #115e59;
  --ui-accent-alt: #ea580c;
  --ui-shadow: 0 14px 40px rgba(15, 39, 49, 0.14);
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--ui-font-body);
  color: var(--ui-text);
  overflow-x: hidden;
  background:
    radial-gradient(1200px 600px at -10% -10%, rgba(15, 118, 110, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(234, 88, 12, 0.16), transparent 55%),
    linear-gradient(140deg, var(--ui-bg-1), var(--ui-bg-2) 50%, var(--ui-bg-3));
}

h1,
h2,
h3,
h4,
h5,
h6,
.fc .fc-toolbar-title {
  font-family: var(--ui-font-heading);
  letter-spacing: 0.01em;
  color: #122f37;
}

.scheduler-page .menu-sidebar {
  background: var(--ui-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  box-shadow: var(--ui-shadow);
  padding: 10px;
  font-size: 0.86rem;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  overflow-x: hidden;
}

.scheduler-page .menu-sidebar h3 {
  font-size: 1.2rem;
  margin-bottom: 0;
}

.scheduler-page .menu-sidebar h6,
.viewer-page .offcanvas-body h6 {
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.scheduler-page .menu-sidebar .row,
.viewer-page .offcanvas-body .row {
  --bs-gutter-x: 0.45rem;
}

.scheduler-page .menu-sidebar .btn,
.viewer-page .offcanvas-body .btn {
  min-height: 32px;
  padding: 0.24rem 0.45rem;
  font-size: 0.78rem;
  border-radius: 9px;
}

.scheduler-page .menu-sidebar .btn i,
.viewer-page .offcanvas-body .btn i {
  font-size: 0.92rem;
}

.scheduler-page .menu-sidebar .form-check-label,
.viewer-page .offcanvas-body .form-check-label {
  font-size: 0.78rem;
}

.scheduler-page .menu-sidebar .form-check,
.viewer-page .offcanvas-body .form-check {
  margin-bottom: 0.2rem;
}

.scheduler-page .menu-sidebar .native-combobox,
.scheduler-page .menu-sidebar .native-datetime-input,
.viewer-page .offcanvas-body .native-combobox,
.viewer-page .offcanvas-body .native-datetime-input {
  font-size: 0.78rem !important;
}

.scheduler-page .main-stage,
.viewer-page .scheduler_container {
  background: var(--ui-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  box-shadow: var(--ui-shadow);
}

.scheduler-page .main-stage {
  padding: 14px 14px 8px;
}

.scheduler-page .content-row {
  height: calc(100vh - 165px);
  min-height: 560px;
}

.scheduler-page #scheduler {
  height: 100%;
  width: 100%;
}

.scheduler-page #scheduler .fc {
  height: 100%;
}

.viewer-page .scheduler_container {
  padding: 10px;
  margin-top: 78px;
}

.viewer-page #scheduler {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 130px);
}

.viewer-page .navbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--ui-border);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(13, 45, 59, 0.08);
}

.btn {
  border-radius: 12px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  box-shadow: 0 3px 10px rgba(13, 50, 64, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(13, 50, 64, 0.18);
}

.btn-info,
.btn-primary {
  background: linear-gradient(120deg, var(--ui-accent), #15948a);
  border-color: transparent;
  color: #ffffff;
}

.btn-secondary {
  background: linear-gradient(120deg, #385766, #2b4d5b);
  border-color: transparent;
  color: #f3f7f8;
}

.card,
.offcanvas,
.modal-content,
.dropdown-menu {
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow);
}

.card {
  background: var(--ui-surface-solid);
}

.form-check-input:checked {
  background-color: var(--ui-accent);
  border-color: var(--ui-accent);
}

.form-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-switch .form-check-input {
  appearance: none;
  -webkit-appearance: none;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 1px solid #94a3b8;
  background: #e2e8f0;
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.form-switch .form-check-input::before {
  content: "";
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.form-switch .form-check-input:checked::before {
  transform: translateX(1rem);
}

.form-switch .form-check-label {
  margin-bottom: 0;
}

.tw-color-picker {
  appearance: none;
  -webkit-appearance: none;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  cursor: pointer;
  min-height: 2.5rem;
  padding: 0.2rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tw-color-picker:hover {
  border-color: #94a3b8;
}

.tw-color-picker:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.22);
  outline: none;
}

.tw-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.tw-color-picker::-webkit-color-swatch {
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
}

.tw-color-picker::-moz-color-swatch {
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
}

.tw-modal-footer [role="alert"] {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.tw-modal-footer [role="alert"] p {
  margin: 0;
  width: 100%;
}

#entity_title {
  font-weight: 700;
  letter-spacing: 0.02em;
}

#scheduler {
  border-radius: 14px;
  overflow: hidden;
}

.fc-theme-bootstrap5 .fc-scrollgrid,
.fc .fc-timegrid-slot,
.fc .fc-col-header-cell,
.fc .fc-daygrid-day-frame {
  border-color: #d7e5e9;
}

.fc .fc-day-today {
  background: rgba(15, 118, 110, 0.08) !important;
}

.fc .fc-button-primary {
  background: linear-gradient(130deg, #244a5a, #1f3f4d) !important;
  border-color: transparent !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 12px rgba(16, 42, 55, 0.2);
}

.fc .fc-button-primary:hover {
  background: linear-gradient(130deg, #2b5a6d, #244a5a) !important;
}

.fc .fc-highlight {
  background: rgba(234, 88, 12, 0.2) !important;
}

.spinner-border {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 0.2em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
  to {
    transform: rotate(360deg);
  }
}

#contextMenu {
  min-width: 200px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #dbe4ea;
  background: rgba(255, 255, 255, 0.98) !important;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(8px);
}

#contextMenu .dropdown-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #7f1d1d;
  background: #fff;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

#contextMenu .dropdown-item i {
  font-size: 0.95rem;
}

#contextMenu .dropdown-item:hover,
#contextMenu .dropdown-item:focus {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fecaca;
}

.native-combobox,
.native-datetime-input,
.native-tree,
.native-listbox,
.native-tree-item,
.native-listbox-item {
  font-family: var(--ui-font-body) !important;
  color: var(--ui-text) !important;
}

.native-combobox,
.native-datetime-input,
.native-listbox,
.native-tree {
  border: 1px solid var(--ui-border) !important;
  border-radius: 10px !important;
  background: var(--ui-surface-solid) !important;
  box-shadow: 0 5px 16px rgba(12, 40, 52, 0.08);
}

.native-listbox-item:hover,
.native-tree-row:hover {
  background: rgba(15, 118, 110, 0.1) !important;
  border-color: rgba(15, 118, 110, 0.2) !important;
}

.native-listbox-item.selected,
.native-tree-item.selected > .native-tree-row {
  background: rgba(15, 118, 110, 0.18) !important;
  border-color: rgba(15, 118, 110, 0.32) !important;
}

.native-tree {
  padding: 8px;
  max-height: 260px;
  overflow: auto;
}

.native-tree-list {
  list-style: none;
  margin: 0;
  padding-left: 8px;
}

.native-tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.native-tree-row.native-drop-target {
  background: rgba(15, 118, 110, 0.12) !important;
}

.native-tree-row.native-drop-before {
  box-shadow: inset 0 3px 0 #0f766e;
}

.native-tree-row.native-drop-after {
  box-shadow: inset 0 -3px 0 #0f766e;
}

.native-listbox {
  overflow: auto;
  padding: 6px;
}

.native-listbox-item {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

#message_notification_success,
#message_notification_warning,
#message_notification_error,
#message_notification_info {
  border: 1px solid var(--ui-border) !important;
  border-radius: 12px !important;
  box-shadow: var(--ui-shadow);
}

/* Modal alert state colors used across controllers */
.alert-primary,
.alert-success {
  border-color: #bbf7d0 !important;
  background-color: #f0fdf4 !important;
  color: #166534 !important;
}

.alert-danger,
.alert-error {
  border-color: #fecaca !important;
  background-color: #fef2f2 !important;
  color: #b91c1c !important;
}

.scheduler-page .header-row,
.viewer-page .topbar-inner {
  animation: fadeInDown 0.45s ease-out;
}

.scheduler-page .content-row,
.viewer-page .scheduler_container {
  animation: fadeInUp 0.55s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 991.98px) {
  .scheduler-page .menu-sidebar {
    position: static !important;
    max-height: none;
    margin-bottom: 12px;
  }

  .scheduler-page .main-stage {
    margin-left: 0;
    padding: 10px;
  }

  .scheduler-page .header-row > div {
    width: 100%;
    margin-bottom: 8px;
    justify-content: flex-start !important;
    text-align: left;
  }

  .scheduler-page .content-row {
    height: auto;
    min-height: 68vh;
  }

  .scheduler-page #scheduler {
    min-height: 68vh;
  }

  .viewer-page .topbar-inner {
    gap: 8px;
    align-items: center;
  }

  .viewer-page .topbar-title {
    width: 100%;
    order: 4;
  }

  .viewer-page #entity_title {
    margin-bottom: 0;
    font-size: 1.15rem;
  }

  .viewer-page #scheduler {
    min-height: calc(100vh - 190px);
  }
}

@media (max-width: 767.98px) {
  .scheduler-page .menu-sidebar {
    padding: 8px;
  }

  .scheduler-page .header-row h3,
  .viewer-page #entity_title {
    font-size: 1rem;
  }

  .scheduler-page .content-row {
    min-height: 62vh;
  }

  .scheduler-page #scheduler,
  .viewer-page #scheduler {
    min-height: 62vh;
  }

  .fc .fc-toolbar {
    gap: 6px;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
  }

  .fc .fc-button {
    padding: 0.22rem 0.45rem;
    font-size: 0.72rem;
  }

  .viewer-page .scheduler_container {
    margin-top: 126px;
    padding: 8px;
  }

  .viewer-page .topbar .inline-flex {
    min-height: 34px;
    font-size: 0.76rem;
  }
}

body.dark-mode {
  color: #dbe7ef;
  background:
    radial-gradient(1200px 600px at -10% -10%, rgba(20, 184, 166, 0.16), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(245, 158, 11, 0.14), transparent 55%),
    linear-gradient(140deg, #0b1220, #111a2a 50%, #1a1325);
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6,
body.dark-mode .fc .fc-toolbar-title,
body.dark-mode #entity_title {
  color: #e6f0f7;
}

body.dark-mode .scheduler-page .menu-sidebar,
body.dark-mode .scheduler-page .main-stage,
body.dark-mode .viewer-page .scheduler_container,
body.dark-mode .viewer-page .topbar,
body.dark-mode .offcanvas,
body.dark-mode .tw-modal-content,
body.dark-mode .card,
body.dark-mode .dropdown-menu,
body.dark-mode .native-combobox,
body.dark-mode .native-datetime-input,
body.dark-mode .native-listbox,
body.dark-mode .native-tree {
  background: rgba(15, 23, 42, 0.86) !important;
  border-color: #334155 !important;
  color: #dbe7ef !important;
}

body.dark-mode .tw-modal-header,
body.dark-mode .tw-modal-footer,
body.dark-mode .offcanvas-header,
body.dark-mode .offcanvas-body {
  border-color: #334155 !important;
}

body.dark-mode .native-tree-row,
body.dark-mode .native-listbox-item,
body.dark-mode .text-slate-700,
body.dark-mode .text-slate-600,
body.dark-mode .text-slate-500,
body.dark-mode label,
body.dark-mode p,
body.dark-mode span,
body.dark-mode small {
  color: #d1deea !important;
}

body.dark-mode .bg-slate-50,
body.dark-mode .bg-slate-100,
body.dark-mode .bg-white,
body.dark-mode .bg-white\/85,
body.dark-mode .bg-white\/90 {
  background-color: rgba(30, 41, 59, 0.85) !important;
}

body.dark-mode .border-slate-200,
body.dark-mode .border-slate-300 {
  border-color: #475569 !important;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
  background: rgba(15, 23, 42, 0.95) !important;
  color: #e2edf5 !important;
  border-color: #475569 !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #94a3b8 !important;
}

body.dark-mode .tw-close-button {
  background: rgba(30, 41, 59, 0.95) !important;
  border-color: #475569 !important;
  color: #e2edf5 !important;
}

body.dark-mode .fc-theme-bootstrap5 .fc-scrollgrid,
body.dark-mode .fc .fc-timegrid-slot,
body.dark-mode .fc .fc-col-header-cell,
body.dark-mode .fc .fc-daygrid-day-frame {
  border-color: #334155 !important;
}

body.dark-mode .fc .fc-daygrid-day,
body.dark-mode .fc .fc-timegrid-col,
body.dark-mode .fc .fc-timegrid-slot,
body.dark-mode .fc .fc-timegrid-axis,
body.dark-mode .fc .fc-col-header-cell,
body.dark-mode .fc .fc-scrollgrid,
body.dark-mode .fc .fc-view-harness {
  background: #0f172a !important;
  color: #dbe7ef !important;
}

body.dark-mode .fc .fc-day-today {
  background: rgba(20, 184, 166, 0.18) !important;
}

body.dark-mode .fc .fc-button-primary {
  background: linear-gradient(130deg, #0f766e, #0f5d7a) !important;
}

body.dark-mode .fc .fc-button-primary:hover {
  background: linear-gradient(130deg, #0d9488, #0e7490) !important;
}

body.dark-mode #entity_title,
body.dark-mode .scheduler-page .menu-sidebar,
body.dark-mode .viewer-page .topbar,
body.dark-mode .viewer-page .offcanvas,
body.dark-mode .fc .fc-toolbar-title,
body.dark-mode .fc .fc-col-header-cell,
body.dark-mode .fc .fc-col-header-cell-cushion {
  color: #000000 !important;
}

body.dark-mode .scheduler-page .menu-sidebar h3,
body.dark-mode #offcanvasNavbarLabel,
body.dark-mode #offcanvasExampleLabel {
  color: #000000 !important;
}

body.dark-mode #contextMenu {
  border-color: #334155 !important;
  background: rgba(15, 23, 42, 0.96) !important;
  box-shadow: 0 16px 30px rgba(2, 6, 23, 0.6);
}

body.dark-mode #contextMenu .dropdown-item {
  color: #fecaca;
  background: #1f2937;
  border-color: transparent;
}

body.dark-mode #contextMenu .dropdown-item:hover,
body.dark-mode #contextMenu .dropdown-item:focus {
  color: #fee2e2;
  background: #7f1d1d;
  border-color: #b91c1c;
}
