/* Desktop & Widget styles — gridstack overrides + widget polish */

/* Make gridstack items fill height properly */
.grid-stack-item-content {
  overflow: hidden;
  border-radius: 0.75rem;
}

.grid-stack-item-content turbo-frame,
.grid-stack-item-content turbo-frame > div {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Gridstack item inset (matches gridstack default) */
.grid-stack > .grid-stack-item > .grid-stack-item-content {
  inset: 4px;
}

/* ── Dark mode — explicit overrides ─────────────────────────────────────────
   Tailwind JIT may miss dark: classes generated from Ruby service strings.
   These rules guarantee correct dark backgrounds regardless of JIT output. */
.dark .grid-stack-item-content turbo-frame > div {
  background-color: #1f2937 !important; /* gray-800 */
  border-color: #374151 !important;     /* gray-700 */
}

/* ── Drag handle ────────────────────────────────────────────────────────── */
.widget-drag-handle {
  cursor: grab;
  user-select: none;
}
.widget-drag-handle:active {
  cursor: grabbing;
}
/* Children must not absorb events — drag must register on the handle div */
.widget-drag-handle > * {
  pointer-events: none;
}

/* ── Gridstack placeholder ──────────────────────────────────────────────── */
.grid-stack-placeholder > .placeholder-content {
  background: rgba(99, 102, 241, 0.08) !important;
  border: 2px dashed rgba(99, 102, 241, 0.35);
  border-radius: 0.75rem;
}
.dark .grid-stack-placeholder > .placeholder-content {
  background: rgba(99, 102, 241, 0.12) !important;
  border-color: rgba(99, 102, 241, 0.45);
}

/* ── Resize handles ─────────────────────────────────────────────────────── */
/* GridStack appends .ui-resizable-handle as sibling to .grid-stack-item-content.
   Must be above content (z-index) and outside the 4px inset area. */
.grid-stack-item > .ui-resizable-handle {
  z-index: 20;
}
.grid-stack-item > .ui-resizable-se,
.grid-stack-item > .ui-resizable-sw {
  bottom: 0;
  width: 20px;
  height: 20px;
  opacity: 0.4;
  transition: opacity 0.15s;
  cursor: se-resize;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M9 1L1 9M9 5L5 9' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px 10px;
}
.grid-stack-item > .ui-resizable-se { right: 0; }
.grid-stack-item > .ui-resizable-sw { left: 0; cursor: sw-resize; }
.grid-stack-item:hover > .ui-resizable-se,
.grid-stack-item:hover > .ui-resizable-sw {
  opacity: 1;
}
.dark .grid-stack-item > .ui-resizable-se,
.dark .grid-stack-item > .ui-resizable-sw {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M9 1L1 9M9 5L5 9' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
