/* ============================================
   MM Solutions Dashboard Modernization v3.0
   Matching Frontend Design System
   ============================================ */

/* Core CSS Variables - Match Frontend */
:root {
  /* Core Colors */
  --color-navy: #0f1f4b;
  --color-brand: #2563eb;
  --color-brand-dark: #1d4ed8;
  --color-brand-light: #3b82f6;
  --color-offwhite: #f5f7fb;
  --color-card: #ffffff;
  --color-divider: #e3e8f2;
  --color-text: #1d2330;
  --color-muted: #64708c;
  --color-white: #ffffff;
  --color-gray-300: #d1d5db;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  --gradient-hero: linear-gradient(135deg, #0f1f4b 0%, #1e3a8a 50%, #2563eb 100%);
  --gradient-sidebar: linear-gradient(180deg, #0f1f4b 0%, #1e3a8a 100%);
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);

  /* Shadows */
  --shadow-xs: 0 2px 4px rgba(15, 31, 75, 0.04);
  --shadow-sm: 0 8px 18px rgba(15, 31, 75, 0.08);
  --shadow-md: 0 22px 44px rgba(15, 31, 75, 0.12);
  --shadow-lg: 0 32px 64px rgba(15, 31, 75, 0.16);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* Spacing */
  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Portal layout overrides to prevent header overlap and improve responsive tables */
.portal-shell.portal-shell--header,
.dashboard-header,
.header-sticky,
.welcome-banner {
  position: static !important;
}

.site-content {
  padding-top: clamp(2.5rem, 5vw, 4.25rem) !important;
  background: #ffffff;
  min-height: 100vh;
}

.site-content__body > *:first-child {
  margin-top: 0;
}

.portal-shell .table-wrap,
.portal-shell .table-responsive,
.table-wrap,
.table-responsive {
  overflow-x: auto;
}

.nav-tabs,
.tabs {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.nav-tabs .nav-link,
.tabs .tab-link {
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .site-content {
    padding-top: clamp(3rem, 10vw, 5rem) !important;
  }
}

.skip-link {
  position: absolute;
  top: -200px;
  left: 1rem;
  padding: 0.75rem 1.25rem;
  background-color: var(--color-brand);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s ease;
  z-index: 9999;
}

.skip-link:focus {
  top: 1rem;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Minimal, safe accessibility bumps (additive) */
a { text-decoration: underline; text-decoration-skip-ink: auto; }
a:hover { text-decoration-thickness: 0.12em; }
::placeholder { color: #6b7280; opacity: 1; }
.overflow-x-auto, .overflow-y-auto, .overflow-auto { overflow: auto; }

/* ============================================
   SIDEBAR MODERNIZATION
   ============================================ */
.site-sidebar {
  background: #ffffff !important;
  box-shadow: 4px 0 24px rgba(15, 31, 75, 0.08);
  border-right: 1px solid var(--color-divider);
}

.site-sidebar .logo {
  padding: var(--space-lg) var(--space-md);
  border-bottom: 2px solid var(--color-divider);
}

.sidebar-menu {
  padding: var(--space-md) var(--space-sm);
}

.sidebar-menu .menu-title {
  color: #ffffff;
  background: var(--color-navy);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: var(--space-md) var(--space-md);
  margin: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-sm);
}

.sidebar-menu li a {
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 3px var(--space-sm);
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 500;
  border: 2px solid transparent;
  background: #0284c7;
}

.sidebar-menu li a:hover {
  background: #0369a1;
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-xs);
}

.sidebar-menu li.active > a {
  background: var(--gradient-primary);
  color: #ffffff;
  border-color: var(--color-brand);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  font-weight: 600;
}

.sidebar-menu .s-icon {
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* ============================================
   DASHBOARD CARDS & CONTAINERS
   ============================================ */
.box.box-block {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-xs);
  padding: var(--space-lg);
  transition: box-shadow var(--transition-base);
}

.box.box-block:hover {
  box-shadow: var(--shadow-sm);
}

/* Content Area */
.content-area {
  padding: var(--space-lg);
}

/* Breadcrumbs */
.breadcrumb {
  background: transparent;
  padding: 0;
  margin: 0;
}

.breadcrumb-item {
  color: var(--color-muted);
}

.breadcrumb-item.active {
  color: var(--color-navy);
  font-weight: 600;
}

.breadcrumb-item a {
  color: var(--color-brand);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb-item a:hover {
  color: var(--color-brand-dark);
}

/* Headings */
h5, .h5 {
  color: var(--color-navy);
  font-weight: 700;
}

/* ============================================
   MODERN BUTTON STYLING
   ============================================ */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 10px 20px;
  transition: all var(--transition-base);
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-xs);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--gradient-primary) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35) !important;
}

.btn-success {
  background: linear-gradient(135deg, #15803d 0%, #047857 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-success:hover {
  box-shadow: 0 8px 20px rgba(21, 128, 61, 0.35) !important;
}

.btn-warning {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-warning:hover {
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.35) !important;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-danger:hover {
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.35) !important;
}

.btn-info {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-info:hover {
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35) !important;
}

.btn-black {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-black:hover {
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.35) !important;
}

/* Button sizes */
.btn-sm {
  padding: 6px 14px;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
}


/* Chat workspace refresh */
.chat-wrapper {
  border-radius: 24px;
  border: 1px solid #e3e8f2;
  padding: 1.5rem;
}

.chat-shell {
  display: flex;
  gap: 2rem;
  align-items: stretch;
}

@media (max-width: 992px) {
  .chat-shell {
    flex-direction: column;
  }
}

.chat-shell__sidebar {
  flex: 0 0 280px;
  max-width: 280px;
}

@media (max-width: 992px) {
  .chat-shell__sidebar {
    max-width: none;
    width: 100%;
  }
}

.chat-shell__main {
  flex: 1 1 auto;
  display: flex;
}

.chat-sidebar {
  background: #f8faff;
  border: 1px solid #e3e8f2;
  border-radius: 20px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.chat-sidebar__header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-sidebar__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #0f1f4b;
}

.chat-sidebar__search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.chat-sidebar__list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: calc(100vh - 260px);
  padding-right: 0.25rem;
}

.chat-sidebar__list::-webkit-scrollbar {
  width: 6px;
}

.chat-sidebar__list::-webkit-scrollbar-thumb {
  background: #cbd5f5;
  border-radius: 6px;
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 14px;
  border: 1px solid transparent;
  background: #fff;
  color: #1d2330;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.chat-contact--thread {
  gap: 0.75rem;
}

.chat-contact:hover {
  border-color: #cbd5f5;
  background: #eef3ff;
}

.chat-contact--active {
  border-color: #2563eb;
  background: #e9f0ff;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

.chat-contact__pin {
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.chat-contact__pin:hover {
  background: rgba(37, 99, 235, 0.08);
}

.chat-contact__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.chat-contact__avatar {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
}

.chat-contact__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-contact__status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #24a148;
}

.chat-contact__status--offline {
  background: #cbd5f5;
}

.chat-contact__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.chat-contact__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f1f4b;
}

.chat-contact__preview {
  font-size: 0.8rem;
  color: #64708c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-contact__meta {
  font-size: 0.75rem;
  color: #64708c;
  margin-left: auto;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 520px;
  border: 1px solid #e3e8f2;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 40px -32px rgba(15, 31, 75, 0.25);
}

.chat-panel__header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e3e8f2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.chat-panel__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f1f4b;
}

.chat-panel__subtitle {
  margin: 0;
  color: #64708c;
  font-size: 0.9rem;
}

.chat-panel__status {
  font-size: 0.8rem;
  color: #64708c;
}

.chat-panel__body {
  flex: 1 1 auto;
  overflow: hidden;
}

.chat-panel__messages {
  height: 100%;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, #f8faff 0%, #ffffff 100%);
}

.chat-panel__messages::-webkit-scrollbar {
  width: 6px;
}

.chat-panel__messages::-webkit-scrollbar-thumb {
  background: #cbd5f5;
  border-radius: 6px;
}

.chat-panel__empty {
  margin: auto;
  padding: 2rem;
  text-align: center;
  color: #64708c;
  font-size: 0.95rem;
}

.chat-bubble {
  display: flex;
  gap: 0.75rem;
  max-width: min(70%, 520px);
  padding: 0.9rem 1.05rem;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(15, 31, 75, 0.08);
  box-shadow: 0 8px 24px -16px rgba(15, 31, 75, 0.35);
}

.chat-bubble--own {
  margin-left: auto;
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 8px 24px -14px rgba(37, 99, 235, 0.65);
}

.chat-bubble__avatar img {
  border-radius: 50%;
  border: 2px solid #fff;
}

.chat-bubble__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-bubble__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: inherit;
  opacity: 0.75;
}

.chat-bubble__meta time {
  margin-left: auto;
  font-size: 0.72rem;
}

.chat-bubble__message {
  margin: 0;
  line-height: 1.45;
  font-size: 0.95rem;
  word-break: break-word;
}

.chat-bubble__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-attachment--image {
  display: block;
  width: 120px;
  height: 90px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(15, 31, 75, 0.08);
}

.chat-attachment--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-attachment--video {
  width: 200px;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(15, 31, 75, 0.08);
}

.chat-attachment--file {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #2563eb;
  list-style: none;
  padding: 0;
}

.chat-attachment--audio {
  width: 220px;
  max-width: 100%;
  border-radius: 12px;
}

.chat-panel__composer {
  border-top: 1px solid #e3e8f2;
  padding: 1rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #fff;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-form__field textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border-radius: 16px;
  border: 1px solid #d7deef;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form__field textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

.chat-form__toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-form__preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #eef3ff;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  color: #2563eb;
}

.chat-preview-chip__remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.chat-form__actions {
  display: flex;
  gap: 0.5rem;
}

.chat-attach-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #d7deef;
  color: #2563eb;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.chat-attach-button:hover {
  border-color: #2563eb;
  background: #eef3ff;
}

.chat-form__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.chat-form__feedback {
  font-size: 0.8rem;
  color: #64708c;
  min-height: 1em;
}

.chat-form__feedback.is-error {
  color: #dc2626;
}

.chat-form__feedback.is-success {
  color: #15803d;
}

.chat-form__send {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding-inline: 1.5rem;
  border-radius: 999px;
}

.chat-form__send[disabled] {
  opacity: 0.6;
  pointer-events: none;
}

@media (max-width: 768px) {
  .chat-panel {
    border-radius: 18px;
  }
  .chat-panel__messages {
    padding: 1rem;
  }
  .chat-attachment--image {
    width: 96px;
    height: 72px;
  }
  .chat-shell__sidebar {
    max-width: 100%;
  }
  .chat-sidebar {
    border-radius: 18px;
    padding: 1rem;
  }
}

/* ============================================
   DASHBOARD TABLES - MODERN STYLING
   ============================================ */
.table {
  background: #fff;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.table thead.thead-inverse th {
  background: var(--color-navy) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 600;
  padding: 16px 18px;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.table thead.thead-inverse th:first-child {
  border-top-left-radius: var(--radius-sm);
}

.table thead.thead-inverse th:last-child {
  border-top-right-radius: var(--radius-sm);
}

.table tbody tr {
  background-color: #ffffff;
  border-bottom: 1px solid var(--color-divider);
  transition: all var(--transition-fast);
}

.table tbody tr:hover {
  background-color: var(--color-offwhite);
  transform: scale(1.002);
}

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

.table tbody td {
  padding: 16px 18px;
  vertical-align: middle;
  color: var(--color-text);
  border-color: var(--color-divider);
}

.table tfoot th {
  background-color: #f3f4f6;
  color: var(--color-navy);
  font-weight: 600;
  padding: 14px 18px;
  border-color: var(--color-divider);
}

/* Button spacing in tables */
.table td .btn {
  margin-right: 6px;
  margin-bottom: 6px;
  font-size: 0.875rem;
  padding: 8px 16px;
  white-space: nowrap;
}

.table td .btn:last-child {
  margin-right: 0;
}

/* Table container - already styled above, this is a fallback */
.table-responsive {
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* DataTables enhancements */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: var(--space-lg);
}

.dataTables_wrapper .dataTables_filter input {
  border: 2px solid var(--color-divider);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-left: 8px;
}

.dataTables_wrapper .dataTables_info {
  padding-top: var(--space-md);
  color: var(--color-muted);
  font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 2px solid var(--color-divider);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 10px 16px !important;
  margin: 0 4px !important;
  border-radius: var(--radius-sm) !important;
  border: 2px solid var(--color-brand) !important;
  background: white !important;
  color: var(--color-brand) !important;
  transition: all var(--transition-fast) !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--color-brand) !important;
  color: white !important;
  border-color: var(--color-brand) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--gradient-primary) !important;
  color: white !important;
  border-color: var(--color-brand) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  border-color: var(--color-divider) !important;
  color: var(--color-muted) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  background: white !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Improve column widths for better visibility */
.table th, .table td {
  white-space: normal;
  word-wrap: break-word;
  min-width: 100px;
}

/* Email columns should be wider */
.table th[data-col-key="email"],
.table td:has(a[href^="mailto"]) {
  min-width: 200px;
}

/* Description/message columns should expand */
.table th[data-col-key="description"],
.table th[data-col-key="message"],
.table td.description-col {
  min-width: 300px;
  max-width: 500px;
}

/* Action columns can be narrower */
.table th[data-col-key="action"],
.table th:last-child {
  min-width: 150px;
}

/* Floating chat: ensure clickability and proper stacking */
.floating-chat-widget { position: fixed; right: 16px; bottom: 16px; z-index: 10000; pointer-events: none; }
.floating-chat-widget .floating-chat-trigger,
.floating-chat-widget .floating-chat-panel { pointer-events: auto; }
.floating-chat-trigger { cursor: pointer; }
.floating-chat-panel { position: fixed; right: 16px; bottom: 72px; max-height: 70vh; overflow: auto; }

/* Keep meeting iframe below chat */
#jitsi-container { position: relative; z-index: 1; }
