/* ─── Dashboard V2 Styles ──────────────────────────────────────────────────── */

/* Shimmer keyframe */
@keyframes dv2-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

/* Grid container — programme onboarding palette (matches /get-started) */
.dv2-grid-container {
  width: 100%;
  min-height: 100%;
  --dv2-po-bg: #fdf7ef;
  --dv2-po-bg-alt: #faf3e9;
  --dv2-po-chrome: #fffdfa;
  --dv2-po-card: rgba(253, 247, 239, 0.38);
  --dv2-po-card-solid: #fffdfa;
  --dv2-po-card-selected: rgba(255, 250, 242, 0.55);
  --dv2-po-border: #f0e4d4;
  --dv2-po-border-field: #ecdcc8;
  --dv2-po-border-accent: #fbd9ac;
  --dv2-po-primary: #f6961d;
  --dv2-po-primary-dark: #b06a12;
  --dv2-po-text: #2a2018;
  --dv2-po-text-body: #3a2e22;
  --dv2-po-text-muted: #7a6f63;
  --dv2-po-text-label: #a8967f;
  /* Map shadcn tokens inside dashboard scope */
  --background: var(--dv2-po-bg);
  --foreground: var(--dv2-po-text);
  --card: var(--dv2-po-card);
  --card-foreground: var(--dv2-po-text);
  --muted-foreground: var(--dv2-po-text-muted);
  --border: var(--dv2-po-border);
  --primary: var(--dv2-po-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Page shell — warm cream like programme onboarding */
.dv2-page {
  position: relative;
  min-height: 100%;
  overflow: visible;
  background: var(--dv2-po-bg);
}

.dv2-page-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0.5;
  filter: blur(64px);
  background:
    radial-gradient(
      ellipse 85% 50% at 0% 0%,
      rgba(246, 150, 29, 0.22),
      transparent 62%
    ),
    radial-gradient(
      ellipse 60% 45% at 85% 15%,
      rgba(251, 217, 172, 0.18),
      transparent 55%
    );
}

.dv2-page-inner {
  position: relative;
  z-index: 1;
}

/* Programme card — frosted warm glass */
.dv2-card--programme {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: var(--dv2-po-card);
  border: 1px solid rgba(240, 228, 212, 0.72);
  box-shadow:
    0 4px 20px rgba(42, 32, 24, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  transition: border-color 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
}

.dv2-card--programme:hover {
  background: var(--dv2-po-card-selected);
  border-color: rgba(251, 217, 172, 0.85);
  transform: translateY(-1px);
  box-shadow:
    0 10px 28px -8px rgba(246, 150, 29, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* Legacy viz widgets — same frosted shell, untouched body */
.dv2-card--legacy {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: var(--dv2-po-card);
  border: 1px solid rgba(240, 228, 212, 0.72);
  box-shadow:
    0 4px 20px rgba(42, 32, 24, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  position: relative;
}

.dv2-card--legacy:hover {
  border-color: rgba(236, 220, 200, 0.9);
  background: var(--dv2-po-card-selected);
}

/* Shared card base (both variants inherit layout) */
.dv2-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

/* Programme card header — very light frosted strip */
.dv2-card--programme .dv2-card-header,
.dv2-card--legacy .dv2-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 9px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border-bottom: 1px solid rgba(240, 228, 212, 0.38);
  background: rgba(253, 247, 239, 0.08);
  backdrop-filter: blur(20px) saturate(1.05);
  -webkit-backdrop-filter: blur(20px) saturate(1.05);
  min-height: 40px;
}

.dv2-card--legacy .dv2-card-header {
  padding-bottom: 8px;
}

/* Category icon — neutral monochrome */
.dv2-cat-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(240, 228, 212, 0.45);
  background: rgba(253, 247, 239, 0.2);
  color: var(--dv2-po-text-label);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dv2-cat-icon svg {
  opacity: 0.85;
}

/* Drag handle */
.dv2-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: -webkit-grab;
  cursor: grab;
  color: var(--muted-foreground, #888);
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
  margin-left: 2px;
}

.dv2-drag-handle:hover {
  color: var(--dv2-po-primary-dark);
  background: #fef1e2;
}

.dv2-drag-handle:active {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

/* Widget title — programme side-title language */
.dv2-widget-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--dv2-po-text-label);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Card content area */
.dv2-card-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Styled resize handle — overrides react-grid-layout default */
.dv2-grid-container .react-resizable-handle {
  width: 18px;
  height: 18px;
  bottom: 4px;
  right: 4px;
  background-image: none;
  padding: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dv2-resize-grip {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: se-resize;
}

.dv2-resize-grip:hover {
  opacity: 0.7;
}

/* Shimmer skeleton */
.dv2-skeleton {
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    rgba(255, 253, 250, 0.45) 0%,
    rgba(255, 250, 242, 0.65) 50%,
    rgba(255, 253, 250, 0.45) 100%
  );
  background-size: 600px 100%;
  animation: dv2-shimmer 1.4s ease-in-out infinite;
  border: 1px solid rgba(240, 228, 212, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Toolbar (kept for potential future use but no longer rendered by default) */
.dv2-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.dv2-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dv2-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Last-updated pill */
.dv2-updated-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fef1e2;
  border: 1px solid var(--dv2-po-border-accent);
  font-size: 11px;
  color: var(--dv2-po-text-muted);
  font-weight: 500;
}

/* Dashboard page header bar — layout/chrome from register-page-hero.css */
.dv2-header-bar {
  padding: 12px clamp(16px, 2.8vw, 24px);
}

html.theme-programme:not(.dark) .dv2-header-bar {
  --page-hero-divider: rgba(234, 217, 193, 0.18);
}

.dv2-header-bar__title {
  font: 700 18px/1.2 'Inter', sans-serif;
  color: var(--dv2-po-text);
  letter-spacing: -0.02em;
}

.dv2-header-bar__sub {
  font: 500 12px/1.4 'Inter', sans-serif;
  color: var(--dv2-po-text-muted);
}

.dv2-header-bar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(254, 241, 226, 0.55);
  border: 1px solid rgba(251, 217, 172, 0.65);
  color: var(--dv2-po-text-label);
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Header section */
.dv2-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 40px 40px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

/* ── Hero header — now rendered via Tailwind in DashboardV2Header.tsx ─────── */
/* Legacy CSS classes retained for structural elements that may still reference them */
.dv2-hero-band {
  position: relative;
  overflow: visible;
}

.dv2-hero-glow {
  display: none;
}

.dv2-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dv2-greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--foreground);
  line-height: 1.2;
}

.dv2-greeting-sub {
  font-size: 13px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dv2-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Status badge in header */
.dv2-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.dv2-status-badge.active {
  background: #fef1e2;
  color: var(--dv2-po-primary-dark);
  border: 1px solid var(--dv2-po-border-accent);
}

/* Category icon bg — warm programme tints */
.dv2-catbg-compliance        { background: #e7f6ec; color: #16a34a; }
.dv2-catbg-tasks             { background: #eef4ff; color: #3b82f6; }
.dv2-catbg-risks             { background: #fef2f2; color: #ef4444; }
.dv2-catbg-data              { background: #ecfeff; color: #06b6d4; }
.dv2-catbg-suppliers         { background: #f5f0ff; color: #8b5cf6; }
.dv2-catbg-documents         { background: #fff8ef; color: #b06a12; }
.dv2-catbg-corrective-actions{ background: #fef1e2; color: #f6961d; }
.dv2-catbg-default           { background: #fef1e2; color: var(--dv2-po-primary-dark); }

/* Empty state */
.dv2-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 320px;
  border: 2px dashed rgba(236, 220, 200, 0.85);
  border-radius: 16px;
  background: rgba(255, 253, 250, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: dv2-fade-in 0.4s ease;
}

@keyframes dv2-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Dragging state */
.react-grid-item.react-draggable-dragging .dv2-card--programme,
.react-grid-item.react-draggable-dragging .dv2-card--legacy {
  box-shadow: 0 16px 40px -12px rgba(246, 150, 29, 0.45);
  transform: scale(1.02);
  border-color: var(--dv2-po-primary);
  z-index: 100;
}

/* Resizing state */
.react-grid-item.resizing .dv2-card--programme,
.react-grid-item.resizing .dv2-card--legacy {
  border-color: var(--dv2-po-primary);
  box-shadow: 0 0 0 2px rgba(246, 150, 29, 0.2);
}

/* ── Dashboard Dropdown Selector ───────────────────────────────────────── */

.dv2-dash-dropdown {
  position: relative;
  z-index: 20;
}

.dv2-dash-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid rgba(240, 228, 212, 0.75);
  background: rgba(255, 253, 250, 0.5);
  color: var(--dv2-po-text-body);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.dv2-dash-dropdown-trigger:hover {
  border-color: rgba(251, 217, 172, 0.9);
  background: rgba(255, 250, 242, 0.72);
  box-shadow: none;
}

.dv2-dash-dropdown-label {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dv2-dash-dropdown-chevron {
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.dv2-dash-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  max-width: 300px;
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid rgba(240, 228, 212, 0.85);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(42, 32, 24, 0.12);
  overflow: hidden;
  padding: 4px 0;
  animation: dv2-dropdown-in 0.15s ease;
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
}

@keyframes dv2-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dv2-dash-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin: 2px 4px;
  border-radius: 8px;
  transition: background 0.1s;
}

.dv2-dash-dropdown-item:hover {
  background: var(--accent, rgba(0, 0, 0, 0.04));
}

.dv2-dash-dropdown-item.active {
  background: #fffaf2;
}

.dv2-dash-dropdown-item-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--foreground);
}

.dv2-dash-dropdown-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.dv2-dash-dropdown-check {
  color: var(--dv2-po-primary-dark);
  flex-shrink: 0;
  margin-left: auto;
}

.dv2-dash-dropdown-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.dv2-dash-dropdown-item:hover .dv2-dash-dropdown-actions {
  opacity: 1;
}

.dv2-dash-dropdown-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.dv2-dash-dropdown-action-btn:hover {
  background: var(--accent, rgba(0, 0, 0, 0.06));
  color: var(--foreground);
}

.dv2-dash-dropdown-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.dv2-dash-dropdown-rename-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  flex: 1;
}

.dv2-dash-dropdown-rename-input {
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--primary);
  outline: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  width: 100%;
  padding: 2px 0;
}

.dv2-dash-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.dv2-dash-dropdown-create {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 2px 4px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--muted-foreground);
  transition: background 0.1s, color 0.1s;
  width: calc(100% - 8px);
  text-align: left;
}

.dv2-dash-dropdown-create:hover:not(:disabled) {
  background: color-mix(in oklch, var(--primary) 8%, transparent);
  color: var(--primary);
  transform: none;
}

.dv2-dash-dropdown-create:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Dashboard header action buttons ───────────────────────────────────── */

.dv2-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dv2-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font: 600 12px 'Inter', sans-serif;
  color: var(--dv2-po-text-body);
  background: rgba(253, 247, 239, 0.45);
  border: 1px solid rgba(240, 228, 212, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: none;
}

.dv2-toolbar-btn:hover:not(:disabled) {
  background: rgba(255, 250, 242, 0.72);
  border-color: rgba(251, 217, 172, 0.9);
  transform: translateY(-1px);
}

.dv2-toolbar-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dv2-toolbar-btn--ghost {
  color: var(--dv2-po-text-muted);
}

.dv2-toolbar-btn--primary {
  color: #fff;
  background: var(--dv2-po-primary);
  border-color: rgba(246, 150, 29, 0.85);
  box-shadow: 0 6px 16px -8px rgba(246, 150, 29, 0.85);
}

.dv2-toolbar-btn--primary:hover:not(:disabled) {
  background: #e8870f;
  border-color: #e8870f;
  box-shadow: 0 8px 20px -8px rgba(246, 150, 29, 0.95);
}

.dv2-toolbar-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.dv2-toolbar-btn--primary .dv2-toolbar-btn__icon {
  background: rgba(255, 255, 255, 0.25);
}

.dv2-toolbar-btn[data-slot='button'] {
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 12px !important;
  border-radius: 999px !important;
  font: 600 12px 'Inter', sans-serif !important;
  box-shadow: none;
}

.dv2-toolbar-btn--primary[data-slot='button'] {
  color: #fff !important;
  background: var(--dv2-po-primary) !important;
  border: 1px solid rgba(246, 150, 29, 0.85) !important;
}

.dv2-toolbar-btn--primary[data-slot='button']:hover:not(:disabled) {
  background: #e8870f !important;
  border-color: #e8870f !important;
}

.dv2-toolbar-btn__icon svg,
.dv2-toolbar-btn__icon img {
  width: 11px;
  height: 11px;
}

