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

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

/* Grid container */
.dv2-grid-container {
  width: 100%;
}

/* Card wrapper */
.dv2-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.08),
    0 1px 4px  rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.25s ease;
  position: relative;
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
}

.dv2-card:hover {
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.14),
    0 3px  8px  rgba(0, 0, 0, 0.06),
    0 0   0 1px color-mix(in oklch, var(--primary) 12%, transparent);
  border-color: color-mix(in oklch, var(--primary) 30%, transparent);
}

/* Card header — neutral grey background (no pink tint) */
.dv2-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
  background: color-mix(in oklch, var(--card) 96%, var(--muted-foreground) 4%);
  min-height: 40px;
}

/* 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-right: 2px;
}

.dv2-drag-handle:hover {
  color: var(--primary);
  background: color-mix(in oklch, var(--primary) 10%, transparent);
}

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

/* Category icon badge */
.dv2-cat-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Widget title */
.dv2-widget-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.01em;
}

/* 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,
    var(--card) 0%,
    color-mix(in oklch, var(--card) 85%, var(--primary) 15%) 50%,
    var(--card) 100%
  );
  background-size: 600px 100%;
  animation: dv2-shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--border);
}

/* 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: color-mix(in oklch, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in oklch, var(--primary) 20%, transparent);
  font-size: 11px;
  color: var(--muted-foreground);
  font-weight: 500;
}

/* 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;
}

/* ── SOA-style hero gradient band ──────────────────────────────────────────── */
.dv2-hero-band {
  position: relative;
  overflow: visible;
  margin: 0 -1.5rem;
  margin-bottom: 12px;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 80%, transparent);
  background: linear-gradient(
    to bottom right,
    color-mix(in oklch, var(--primary) 15%, transparent) 0%,
    var(--background, #f8fafc) 50%,
    var(--background, #f8fafc) 100%
  );
}

/* Radial glow blob */
.dv2-hero-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0.25;
  filter: blur(48px);
  background: radial-gradient(
    ellipse at top left,
    color-mix(in oklch, var(--primary) 50%, transparent) 0%,
    transparent 50%,
    transparent 100%
  );
}

.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: color-mix(in oklch, var(--primary) 12%, transparent);
  color: color-mix(in oklch, var(--primary) 80%, var(--foreground) 20%);
  border: 1px solid color-mix(in oklch, var(--primary) 25%, transparent);
}

/* Category icon bg colours */
.dv2-catbg-compliance        { background: rgba(16,185,129,0.12); color: #10b981; }
.dv2-catbg-tasks             { background: rgba(59,130,246,0.12); color: #3b82f6; }
.dv2-catbg-risks             { background: rgba(239,68,68,0.12);  color: #ef4444; }
.dv2-catbg-data              { background: rgba(6,182,212,0.12);  color: #06b6d4; }
.dv2-catbg-suppliers         { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.dv2-catbg-documents         { background: rgba(245,158,11,0.12); color: #f59e0b; }
.dv2-catbg-corrective-actions{ background: rgba(249,115,22,0.12); color: #f97316; }
.dv2-catbg-default           { background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); }

/* Empty state */
.dv2-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 320px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: color-mix(in oklch, var(--card) 60%, transparent);
  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 {
  box-shadow:
    0 28px 64px rgba(0, 0, 0, 0.22),
    0 8px  20px rgba(0, 0, 0, 0.10),
    0 0    0 1.5px var(--primary);
  transform: scale(1.025);
  border-color: var(--primary);
  z-index: 100;
}

/* Resizing state */
.react-grid-item.resizing .dv2-card {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--primary) 30%, transparent);
}

/* ── 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: 1.5px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.dv2-dash-dropdown-trigger:hover {
  border-color: color-mix(in oklch, var(--primary) 40%, var(--border));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.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: var(--popover, var(--card));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  padding: 4px 0;
  animation: dv2-dropdown-in 0.15s ease;
}

@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: color-mix(in oklch, var(--primary) 10%, transparent);
}

.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(--primary);
  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);
}

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