/* app/assets/stylesheets/components/tiles.css
   Tiling working area — chromeless panes split by hairline separators. A new pane splits the
   largest pane; you can drag a separator to resize, swap two panes, extract a pane to a tab, or
   close it. (Collapse is intentionally off for now.)
   The pane is lean; the content decides its own header (embeds get a title bar, app views bring
   their own heading). */

/* .tiles-area fills its parent's height — the host gives it a definite-height ancestor
   (the app shell's `flex-1 min-h-0` scroll container provides this). */
.tiles-area { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tiles-tree { flex: 1 1 auto; display: flex; min-width: 0; min-height: 0; }
/* The master tile's content frame is layout-transparent — its children flow directly in the
   tile body (the scroll container), so wrapping the page in it changes nothing visually. */
turbo-frame#app_content { display: contents; }
.tiles-node { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; }
.tiles-node--row { flex-direction: row; }
.tiles-node--col { flex-direction: column; }

/* a pane: bare content, no border/shadow */
.tile { position: relative; display: flex; flex-direction: column; flex: 1 1 0; min-width: 34px; min-height: 34px; background: #fff; overflow: hidden; }
.tile.is-flash::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--color-gondola, #007390); animation: tile-flash .9s ease forwards; pointer-events: none; z-index: 5; }
@keyframes tile-flash { to { box-shadow: inset 0 0 0 0 rgba(0,0,0,0); } }

.tile-body { flex: 1 1 auto; overflow: auto; min-width: 0; min-height: 0; background: #fff; }
/* app views breathe; embeds fill. The master pane is now the app's main scroll container, so
   match the shell's responsive page padding (px-3 sm:px-4 md:px-5 lg:px-6 py-5) exactly. */
.tile-body:not(.is-embed) { padding: 20px 12px; }
@media (min-width: 640px)  { .tile-body:not(.is-embed) { padding-left: 16px; padding-right: 16px; } }
@media (min-width: 768px)  { .tile-body:not(.is-embed) { padding-left: 20px; padding-right: 20px; } }
@media (min-width: 1024px) { .tile-body:not(.is-embed) { padding-left: 24px; padding-right: 24px; } }
.tile-body.is-embed { background: #525659; overflow: hidden; padding: 0; }
.tile-body .tile-frame, .tile-body .tile-iframe { width: 100%; height: 100%; border: 0; display: block; }

/* documents: a slim title bar (filename + actions) ABOVE the iframe, so the browser's native
   PDF/image toolbar stays reachable (floating controls would cover it) */
.tile-bar { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: #f8fafc; border-bottom: 1px solid #eef2f4; flex: 0 0 auto; }
.tile-bar-title { font-size: 12px; font-weight: 600; color: #334155; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-bar-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.tile-bar .tile-btn { background: transparent; box-shadow: none; backdrop-filter: none; }
.tile-bar .tile-btn:hover { background: var(--color-gondola-light, #DFEEF1); }

/* app-view panes: chromeless — controls float over the corner and fade in on hover/focus */
.tile-chrome { position: absolute; top: 0; right: 0; display: flex; padding: 6px 8px; pointer-events: none; z-index: 3; }
.tile-actions { pointer-events: auto; display: flex; gap: 3px; opacity: 0; transition: opacity .12s ease; }
.tile:hover .tile-actions, .tile.is-focused .tile-actions { opacity: 1; }
.tile-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); color: #64748b; box-shadow: 0 1px 3px rgba(15,23,42,.12); font-size: 12px; line-height: 1; cursor: pointer; }
.tile-btn:hover { color: var(--color-gondola-dark, #006380); background: #fff; }
.tile-btn.is-close:hover { color: #b91c1c; }

/* hairline separator — drag it to resize the two panes it divides (double-click resets to half and
   half). The swap button always sits in the middle as its grip: click to swap, press and move to
   drag. Hover/focus thickens the line to brand teal. ::before widens the grab zone. */
.tiles-gutter { flex: 0 0 1px; background: #e5e7eb; position: relative; z-index: 4; outline: none; touch-action: none; transition: background-color .12s ease, box-shadow .12s ease; }
.tiles-gutter--row { cursor: col-resize; }
.tiles-gutter--col { cursor: row-resize; }
.tiles-gutter::before { content: ""; position: absolute; }
.tiles-gutter--row::before { top: 0; bottom: 0; left: -5px; right: -5px; }
.tiles-gutter--col::before { left: 0; right: 0; top: -5px; bottom: -5px; }
.tiles-gutter:hover, .tiles-gutter:focus-visible, .tiles-gutter.is-dragging { background: var(--color-gondola, #007390); box-shadow: 0 0 0 1px var(--color-gondola, #007390); }
.tiles-gutter-controls { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; z-index: 6; }
.tiles-gutter-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 1px solid #e5e7eb; border-radius: 5px; background: #fff; color: #94a3b8; box-shadow: 0 1px 3px rgba(15,23,42,.18); font-size: 12px; line-height: 1; cursor: pointer; transition: color .12s ease, border-color .12s ease; }
.tiles-gutter:hover .tiles-gutter-btn, .tiles-gutter:focus-visible .tiles-gutter-btn, .tiles-gutter.is-dragging .tiles-gutter-btn { color: var(--color-gondola, #007390); border-color: var(--color-gondola, #007390); }
/* while dragging, a transparent shield covers the viewport so no pane or document <iframe> can take
   the pointer; it also holds the resize cursor. */
.tiles-drag-shield { position: fixed; inset: 0; z-index: 2147483000; background: transparent; }
.tiles-drag-shield--row { cursor: col-resize; }
.tiles-drag-shield--col { cursor: row-resize; }
.tiles-area.is-dragging { user-select: none; }

/* mobile: one pane at a time (the tree shows only the active pane) */
@media (max-width: 767px) {
  .tiles-tree.is-mobile .tile:not(.is-active-mobile) { display: none; }
  .tiles-tree.is-mobile .tiles-node { flex-direction: column; }
  .tiles-tree.is-mobile .tiles-gutter { display: none; }
}
