/* LacaStay Signage — Juuno-like look, own CSS: off-white content background,
   white sidebar, white cards with soft shadow and large corners, near-black
   text, black pill primary buttons, gray secondary text. LacaStay logo kept. */
* { box-sizing: border-box; }
body { margin: 0; font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: #111111; background: #F4F4F5; }
a { color: #111111; }
button, input, select, textarea { font: inherit; }

/* Mobile-only slim header (hamburger + logo); desktop has no top bar —
   each page carries its own header in the content area. */
#mobile-header { display: none; }
.side-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
#brand-logo, #mobile-logo { height: 34px; width: auto; }
.brand-name { font-size: 20px; font-weight: 800; color: #111111; }
.side-loc { font-size: 13px; color: #737373; display: block; margin-bottom: 12px; font-weight: 600; }
.side-loc select { display: block; width: 100%; margin-top: 6px; border: 1px solid #D4D4D4; border-radius: 10px; padding: 8px 10px; background: #fff; color: #111111; }
.plan-badge { background: #F0F0F0; color: #525252; border: 1px solid #E5E5E5; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 700; white-space: nowrap; display: inline-block; margin-bottom: 10px; }

/* Layout */
#layout { display: flex; min-height: 100vh; }
#sidebar { width: 230px; background: #fff; border-right: 1px solid #E7E7E7; padding: 18px 14px; flex-shrink: 0; }
#sidebar nav button { display: block; width: 100%; text-align: left; background: none; border: none; color: #525252; padding: 11px 12px; border-radius: 10px; font-size: 15px; cursor: pointer; margin-bottom: 4px; }
#sidebar nav button:hover { background: #F5F5F5; }
#sidebar nav button.active { background: #EDEDED; color: #111111; font-weight: 700; }
.side-foot { margin-top: 28px; border-top: 1px solid #E7E7E7; padding-top: 14px; font-size: 12.5px; color: #737373; }
.side-foot .btn { display: block; width: 100%; text-align: center; margin-bottom: 8px; }
#main { flex: 1; padding: 26px 30px; max-width: 1120px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.view-head h1 { margin: 0; font-size: 30px; font-weight: 800; color: #111111; }
.crumb { font-size: 13px; color: #737373; margin-bottom: 4px; }
.hint { color: #737373; font-size: 14px; max-width: 820px; }
.cards { display: grid; gap: 14px; margin-top: 16px; }
.card { background: #fff; border: 1px solid #E7E7E7; border-radius: 16px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04); }
.card h2 { margin: 0 0 12px; font-size: 20px; font-weight: 700; color: #111111; }
.card h3 { margin: 16px 0 8px; font-size: 15px; }
.btn { border: 1px solid #D4D4D4; background: #fff; border-radius: 999px; padding: 8px 16px; font-size: 14px; cursor: pointer; color: #111111; text-decoration: none; display: inline-block; }
.btn:hover { border-color: #111111; }
.btn.primary { background: #111111; color: #fff; border-color: #111111; font-weight: 700; }
.btn.primary:hover { background: #333333; }
.btn:disabled { background: #F0F0F0; color: #A3A3A3; border-color: #E7E7E7; cursor: not-allowed; }
.btn.danger { color: #B91C1C; border-color: #FECACA; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { margin: 8px 0; }
.field label { display: block; font-size: 13px; color: #737373; margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid #D4D4D4; border-radius: 10px; font-size: 14px; background: #fff; color: #111111; }
.field input[type="checkbox"] { width: auto; }
.field input:disabled, .field select:disabled { background: #F5F5F5; color: #737373; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }
.badge { display: inline-block; background: #F0F0F0; color: #525252; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.badge.green { background: #DCFCE7; color: #166534; }
.badge.gray { background: #F0F0F0; color: #737373; }
.badge.red { background: #FEE2E2; color: #991B1B; }
.item-row { border: 1px solid #E7E7E7; border-radius: 16px; padding: 12px; margin-bottom: 10px; background: #fff; }
.menu-cat { border: 1px solid #E7E7E7; border-radius: 16px; padding: 12px; margin-bottom: 12px; background: #fff; }
.menu-item-row { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: 8px; margin-bottom: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.media-card img, .media-card video { width: 100%; height: 140px; object-fit: cover; border-radius: 12px; background: #111111; }
.media-card .name { font-size: 13px; word-break: break-all; margin-top: 6px; }
.media-card .meta { font-size: 12px; color: #737373; }
.muted { color: #737373; font-size: 13px; }
.muted.small { font-size: 12.5px; }
.error { color: #B91C1C; font-size: 13px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: #737373; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 2px solid #E7E7E7; }
table.data td { padding: 9px 10px; border-bottom: 1px solid #F0F0F0; vertical-align: top; }
.bar { height: 8px; background: #111111; border-radius: 4px; }

/* ---- Screens / Playlists redesign (Juuno-style management) ---- */
.badge.blue { background: #DBEAFE; color: #1D4ED8; }
.search-input { border: 1px solid #D4D4D4; border-radius: 999px; padding: 8px 14px; font-size: 14px; background: #fff; color: #111111; width: 200px; }
.now-playing { font-weight: 700; font-size: 14px; margin: 4px 0 2px; color: #111111; }
.used-by { font-size: 13px; color: #737373; margin-top: 2px; }
.screen-edit { border-top: 1px solid #E7E7E7; margin-top: 14px; padding-top: 14px; }
.screen-edit:empty { display: none; }
.add-groups { display: grid; gap: 12px; margin-top: 12px; }
.add-group { border: 1px solid #E7E7E7; border-radius: 16px; padding: 12px; background: #fff; }
.add-group > strong { display: block; margin-bottom: 8px; font-size: 13px; color: #737373; text-transform: uppercase; letter-spacing: 0.04em; }
.cast-picker:empty { display: none; }

/* ---- First-run wizard ---- */
.wizard-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.wizard-card { background: #fff; border-radius: 20px; padding: 26px 26px 20px; width: 100%; max-width: 520px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18); max-height: 92dvh; overflow-y: auto; }
.wizard-card h2 { margin: 0 0 10px; font-size: 21px; font-weight: 800; text-align: center; color: #111111; }
.wizard-card ol { color: #525252; font-size: 14.5px; line-height: 1.7; padding-left: 20px; }
.wizard-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.wz-dot { font-size: 12px; font-weight: 700; color: #94A3B8; background: #F0F0F0; border-radius: 999px; padding: 4px 10px; }
.wz-dot.active { color: #fff; background: #111111; }
.wz-dot.done { color: #166534; background: #DCFCE7; }
.wizard-opt { border: 1px solid #E7E7E7; border-radius: 16px; padding: 14px; background: #fff; }
.wizard-skip { margin-top: 16px; width: 100%; background: none; border: none; color: #737373; cursor: pointer; font-size: 13.5px; }
.wizard-skip:hover { color: #111111; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border: 1px solid #E7E7E7; border-radius: 20px; padding: 30px 28px; width: 100%; max-width: 400px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08); text-align: center; }
.login-logo { height: 44px; width: auto; }
.login-card h1 { margin: 10px 0 4px; font-size: 24px; }
.login-card form { text-align: left; margin-top: 16px; }

/* ---- UI refresh: collapsible sidebar, mobile drawer, touch targets ---- */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #111111; outline-offset: 2px; }
#sidebar { display: flex; flex-direction: column; }
#btn-hamburger { display: none; }
#btn-sidebar-close { display: none; align-self: flex-end; margin-bottom: 8px; }
.icon-btn { border: 1px solid #D4D4D4; background: #fff; border-radius: 999px; width: 44px; height: 44px; min-width: 44px; font-size: 20px; line-height: 1; cursor: pointer; color: #111111; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: #111111; }
.collapse-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 1px solid #E7E7E7; border-radius: 999px; padding: 10px 12px; font-size: 13px; color: #737373; cursor: pointer; margin-bottom: 12px; }
.collapse-btn:hover { background: #F5F5F5; }
#sidebar nav { flex: 1; }
#sidebar nav button { display: flex; align-items: center; gap: 10px; }
.nav-icon { display: inline-flex; flex-shrink: 0; color: #737373; }
#sidebar nav button.active .nav-icon { color: #111111; }
.nav-icon svg { width: 20px; height: 20px; }
.nav-label { flex: 1; }
.side-foot { margin-top: auto !important; }
#sidebar-overlay { display: none; }

/* Toast (success / error feedback after actions) */
#toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #111111; color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); text-align: center; }
.toast.error { background: #B91C1C; }

/* Empty states: what is missing + what to do next */
.empty-state { background: #fff; border: 1px dashed #D4D4D4; border-radius: 16px; padding: 22px 24px; margin-top: 16px; }
.empty-state h3 { margin: 0 0 8px; font-size: 17px; }
.empty-state ol { margin: 8px 0 16px; padding-left: 20px; color: #737373; font-size: 14px; line-height: 1.65; }
.empty-state ol li { margin-bottom: 4px; }

#btn-logout-side { display: none; }

/* Collapsed sidebar: desktop only, icon strip */
@media (min-width: 769px) {
  body.sidebar-collapsed #sidebar { width: 72px; padding: 18px 10px; }
  body.sidebar-collapsed .nav-label, body.sidebar-collapsed .side-foot, body.sidebar-collapsed .collapse-label, body.sidebar-collapsed .side-loc { display: none; }
  body.sidebar-collapsed .side-brand { justify-content: center; }
  body.sidebar-collapsed .side-brand .brand-name { display: none; }
  body.sidebar-collapsed #sidebar nav button { justify-content: center; padding: 11px 0; }
  body.sidebar-collapsed .collapse-btn { justify-content: center; padding: 10px 0; }
}

/* Mobile: drawer menu, stacked forms, cards instead of tables */
@media (max-width: 768px) {
  #mobile-header { display: flex; align-items: center; gap: 10px; background: #fff; border-bottom: 1px solid #E7E7E7; padding: 10px 12px; position: sticky; top: 0; z-index: 30; }
  #mobile-logo { height: 28px; width: auto; }
  #mobile-header .brand-name { font-size: 18px; }
  #btn-hamburger, #btn-sidebar-close { display: inline-flex; }
  .side-brand { display: none; }
  .collapse-btn { display: none; }
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; z-index: 50; width: 280px; max-width: 85vw; transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18); overflow-y: auto; }
  body.sidebar-open #sidebar { transform: none; }
  body.sidebar-open #sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 40; }
  #main { padding: 16px; min-width: 0; }
  .view-head h1 { font-size: 22px; }
  .view-head .btn.primary { min-height: 44px; }
  .btn { padding: 11px 14px; min-height: 44px; }
  .btn.small { padding: 9px 12px; min-height: 40px; font-size: 13px; }
  .field input, .field select, .field textarea { padding: 12px; font-size: 15px; }
  .grid2 { grid-template-columns: 1fr; }
  .menu-item-row { grid-template-columns: 1fr; }
  .menu-item-row input { width: 100%; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .empty-state { padding: 18px 16px; }
  /* Tables become cards: each row is a block, cells carry their label */
  table.data, table.data tbody { display: block; width: 100%; }
  table.data tr { display: block; border: 1px solid #F0F0F0; border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; }
  table.data tr:has(> th) { display: none; }
  table.data th { display: none; }
  table.data td { display: flex; justify-content: space-between; gap: 12px; border-bottom: none; padding: 6px 0; text-align: right; }
  table.data td[data-label]::before { content: attr(data-label); color: #737373; font-size: 12.5px; text-align: left; flex-shrink: 0; }
  table.data td .bar { min-width: 60px; }
  .search-input { width: 100%; }
  .wizard-card { padding: 20px 16px; }
}

/* ---- Juuno-style playlist editor: drag-drop, item menu, durations ---- */
.pl-item-row { position: relative; }
.item-head { position: relative; flex-wrap: nowrap; }
.item-head select[data-f="type"] { flex: 1; min-width: 0; border: 1px solid #D4D4D4; border-radius: 10px; padding: 8px 10px; background: #fff; color: #111111; font-size: 14px; }
.drag-handle { display: inline-flex; align-items: center; color: #A3A3A3; cursor: grab; flex-shrink: 0; padding: 4px 2px; touch-action: none; }
.drag-handle:hover { color: #111111; }
.drag-handle svg { width: 20px; height: 20px; }
.drag-handle:active { cursor: grabbing; }
.duration-link { border: none; background: none; cursor: pointer; font-weight: 600; color: #111111; font-variant-numeric: tabular-nums; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; flex-shrink: 0; }
.duration-link:hover { color: #525252; }
.item-menu-btn { border: 1px solid #D4D4D4; background: #fff; border-radius: 999px; width: 36px; height: 36px; min-width: 36px; font-size: 20px; line-height: 1; cursor: pointer; color: #111111; flex-shrink: 0; }
.item-menu-btn:hover { border-color: #111111; }
.item-menu { position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid #E7E7E7; border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); padding: 6px; z-index: 20; min-width: 160px; }
.item-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 9px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; color: #111111; }
.item-menu button:hover { background: #F5F5F5; }
.item-menu button.danger { color: #B91C1C; }
.duration-popover { position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid #E7E7E7; border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); padding: 12px; z-index: 20; }
.duration-popover select { border: 1px solid #D4D4D4; border-radius: 10px; padding: 8px; background: #fff; color: #111111; font-size: 14px; }
.pl-item-row.selected { border-color: #111111; background: #FAFAFA; }
.pl-item-row.flash { outline: 2px solid #111111; outline-offset: 1px; }
.pl-item-row.drag-source { display: none; }
.drag-float { position: fixed; z-index: 300; pointer-events: none; opacity: 0.97; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); margin: 0; }
body.pl-dragging, body.pl-dragging .pl-item-row { user-select: none; }
.drop-indicator { height: 3px; background: #111111; border-radius: 999px; margin: 6px 0; }
#pl-items.pl-drop-active { outline: 2px dashed #A3A3A3; outline-offset: 4px; border-radius: 16px; }
.drop-empty { border: 2px dashed #D4D4D4; border-radius: 16px; padding: 30px 20px; text-align: center; background: #fff; }
.drop-empty strong { font-size: 16px; }
.drop-empty p { color: #737373; font-size: 14px; margin: 8px 0 0; }
.sel-bar { display: flex; gap: 10px; align-items: center; background: #111111; color: #fff; border-radius: 999px; padding: 8px 14px; margin-bottom: 12px; font-size: 14px; }
.sel-bar .btn { border-color: #fff; color: #fff; background: transparent; }
.sel-bar .btn.danger { color: #FCA5A5; border-color: #FCA5A5; }
.add-panel { margin-top: 16px; }
.add-panel .search-input { width: 180px; }
.add-panel select { border: 1px solid #D4D4D4; border-radius: 999px; padding: 8px 12px; background: #fff; color: #111111; font-size: 14px; }
#add-groups { display: grid; gap: 12px; margin-top: 12px; }

/* ---- Generic modal (item preview, Add from URL) ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.modal-card { position: relative; background: #fff; border-radius: 20px; padding: 26px; width: 100%; max-width: 520px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18); max-height: 92dvh; overflow-y: auto; }
.modal-title { margin: 0 0 10px; font-size: 21px; font-weight: 800; text-align: center; color: #111111; }
.modal-desc { color: #737373; font-size: 14px; text-align: center; margin: 0 0 12px; }
.modal-x { position: absolute; top: 12px; right: 12px; border: 1px solid #D4D4D4; background: #fff; border-radius: 999px; width: 36px; height: 36px; font-size: 20px; line-height: 1; cursor: pointer; color: #111111; }
.modal-x:hover { border-color: #111111; }

/* ---- Pill toggle (black when on, gray when off) ---- */
.pill-toggle { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; font-size: 14px; }
.pill-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.pill-track { width: 44px; height: 24px; border-radius: 999px; background: #D4D4D4; position: relative; flex-shrink: 0; transition: background 0.15s ease; }
.pill-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 999px; background: #fff; transition: left 0.15s ease; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.pill-toggle input:checked + .pill-track { background: #111111; }
.pill-toggle input:checked + .pill-track .pill-knob { left: 23px; }
.pill-toggle input:focus-visible + .pill-track { outline: 2px solid #111111; outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

@media (max-width: 768px) {
  .item-head { flex-wrap: wrap; }
  .item-head select[data-f="type"] { flex: 1 1 55%; }
  .duration-popover { max-width: calc(100vw - 64px); }
  .add-panel .search-input { width: 100%; }
  .modal-card { padding: 20px 16px; }
}
