/* Newspaper Page Designer — standalone, zero dependencies */
@font-face {
  font-family: 'Noto Sans Bengali';
  src: url('fonts/NotoSansBengali.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
:root {
  --bg: #e8e8e8; --panel: #f4f4f4; --panel2: #ddd; --ink: #222; --muted: #666;
  --accent: #0057a8; --sel: #2a7fff; --border: #bbb; --page-bg: #fff;
  --font-ui: 'Noto Sans Bengali', 'SutonnyMJ', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font-ui); font-size: 13px; color: var(--ink); }
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
/* Menubar */
#menubar { display: flex; align-items: center; gap: 8px; background: #2b2b2b; color: #eee; padding: 0 8px; height: 38px; flex: 0 0 auto; }
#menubar .logo { font-weight: 700; white-space: nowrap; margin-right: 8px; }
#menus { display: flex; gap: 2px; }
.menu { position: relative; }
.menu > button { background: none; border: 0; color: #eee; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.menu > button:hover, .menu.open > button { background: #444; }
.dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 260px; background: #fff; color: #222; border: 1px solid #999; box-shadow: 0 4px 16px rgba(0,0,0,.35); z-index: 100; padding: 4px 0; }
.menu.open .dropdown { display: block; }
.dropdown a { display: flex; justify-content: space-between; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.dropdown a:hover { background: var(--accent); color: #fff; }
.dropdown a span { color: #888; margin-left: 24px; }
.dropdown a:hover span { color: #cde; }
.dropdown hr { border: 0; border-top: 1px solid #ddd; margin: 4px 0; }
#docTitle { margin-left: auto; font-weight: 600; }
#saveState { color: #9fd6a0; font-size: 12px; }
/* Main layout */
#main { display: flex; flex: 1; min-height: 0; }
#tools { width: 52px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 4px 0; gap: 2px; overflow-y: auto; flex: 0 0 auto; }
.tool { width: 42px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 17px; cursor: pointer; border: 1px solid transparent; border-radius: 3px; background: #fff; }
.tool:hover { border-color: var(--accent); }
.tool.active { background: var(--accent); color: #fff; }
#workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #cfcfcf; }
#rulerH { height: 20px; background: var(--panel); border-bottom: 1px solid var(--border); background-image: repeating-linear-gradient(90deg, transparent 0 35px, #999 35px 36px); flex: 0 0 auto; margin-left: 20px; }
#canvasWrap { flex: 1; display: flex; min-height: 0; overflow: auto; }
#rulerV { width: 20px; background: var(--panel); border-right: 1px solid var(--border); background-image: repeating-linear-gradient(180deg, transparent 0 35px, #999 35px 36px); flex: 0 0 auto; }
#pasteboard { flex: 1; padding: 28px; overflow: auto; position: relative; }
#page { position: relative; margin: 0 auto; background: var(--page-bg); box-shadow: 0 2px 18px rgba(0,0,0,.4); transform-origin: top center; }
#page .bleed { position: absolute; border: 1px dashed #c00; pointer-events: none; }
#page .margin-guide { position: absolute; border: 1px solid #3a7bd5; pointer-events: none; }
#page .col-guide { position: absolute; background: rgba(255,0,180,.10); border-left: 1px solid rgba(255,0,180,.5); border-right: 1px solid rgba(255,0,180,.5); pointer-events: none; }
#page .guide-line { position: absolute; background: #0a0; pointer-events: none; }
.item { position: absolute; outline: 1px solid transparent; }
.item:hover { outline-color: #9db8d6; }
.item.selected { outline: 2px solid var(--sel); }
.item .overflow-badge { position: absolute; right: -6px; bottom: -6px; background: #d00; color: #fff; border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; z-index: 5; }
.item .link-tab { position: absolute; top: -16px; left: 4px; background: #eee; border: 1px solid #999; font-size: 10px; padding: 0 4px; color: #333; }
.item .handle { position: absolute; width: 9px; height: 9px; background: #fff; border: 1px solid var(--sel); z-index: 6; }
.item .handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.item .handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.item .handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.item .handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.textbox { overflow: hidden; word-wrap: break-word; }
.textbox[contenteditable="true"]:focus { outline: 2px solid var(--sel); }
.picbox img { width: 100%; height: 100%; object-fit: fill; display: block; }
.picbox.fit-prop img { object-fit: contain; }
.picbox .crop-hint { position: absolute; inset: 0; display: none; }
.tablebox table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
.tablebox td { border: 1px solid #333; padding: 2px; vertical-align: top; overflow: hidden; font-size: 11px; }
.tablebox td.piccell img { width: 100%; height: 100%; object-fit: cover; }
#statusbar { flex: 0 0 auto; display: flex; gap: 16px; background: var(--panel); border-top: 1px solid var(--border); padding: 4px 10px; font-size: 12px; color: var(--muted); }
#statusMsg { color: var(--accent); font-weight: 600; }
/* Palettes */
#palettes { width: 268px; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; flex: 0 0 auto; }
.palette { border-bottom: 1px solid var(--border); }
.palette h3 { margin: 0; padding: 6px 8px; background: var(--panel2); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.palette h3 .kbd { font-weight: 400; color: var(--muted); font-size: 11px; }
.palette h4 { margin: 8px 0 4px; font-size: 12px; }
.palette .pbody { padding: 8px; }
.palette label { display: flex; gap: 4px; align-items: center; margin: 3px 0; font-size: 12px; }
.palette input[type="number"] { width: 64px; }
.palette input[type="text"], .palette select { flex: 1; min-width: 0; }
.palette ul { list-style: none; margin: 0; padding: 0; }
.palette li { padding: 4px 6px; cursor: pointer; border: 1px solid transparent; }
.palette li:hover { background: #e3eefc; }
.palette li.selected { background: #cfe3fb; border-color: var(--sel); }
.palette .row { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.palette button { cursor: pointer; }
.palette .hint { font-size: 11px; color: var(--muted); }
.palette .info { font-size: 11px; color: #064; background: #e6f4ea; padding: 4px; margin-top: 6px; white-space: pre-line; }
#colorSwatches { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.swatch { width: 28px; height: 28px; border: 1px solid #888; cursor: pointer; }
.swatch.selected { outline: 2px solid var(--sel); }
/* Dialog */
#dlgOverlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 200; }
#dlgOverlay.hidden { display: none; }
#dlg { background: #fff; border: 1px solid #666; box-shadow: 0 8px 40px rgba(0,0,0,.5); padding: 16px; width: min(620px, 92vw); max-height: 86vh; overflow: auto; }
#dlg h2 { margin: 0 0 10px; font-size: 16px; }
#dlg label { display: block; margin: 6px 0; }
#dlg input[type="number"], #dlg input[type="text"], #dlg select, #dlg textarea { width: 100%; padding: 4px; }
#dlg textarea { min-height: 120px; font-family: inherit; }
#dlg .dlg-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
#dlg .note { background: #fff8e1; border: 1px solid #e6c200; padding: 8px; font-size: 12px; margin: 8px 0; }
#dlg .warn { background: #fdecea; border: 1px solid #d33; padding: 8px; font-size: 12px; margin: 8px 0; }
#dlg table { border-collapse: collapse; width: 100%; }
#dlg td, #dlg th { border: 1px solid #ccc; padding: 4px 6px; text-align: left; font-size: 12px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 8px 16px; border-radius: 4px; opacity: 0; transition: opacity .2s; z-index: 300; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
.collapse { background: none; border: 0; cursor: pointer; font-size: 14px; }
/* Login gate — the app is hidden until login succeeds (js/auth.js) */
body.locked #app { display: none; }
#loginOverlay { position: fixed; inset: 0; background: #1c1c1c; display: flex; align-items: center; justify-content: center; z-index: 500; }
#loginOverlay.hidden { display: none; }
#loginBox { background: #fff; padding: 28px; width: min(420px, 92vw); border: 1px solid #666; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
#loginBox h1 { margin: 0 0 4px; font-size: 19px; }
#loginBox h2 { margin: 0 0 6px; font-size: 15px; }
#loginBox label { display: block; margin: 10px 0; }
#loginBox input { width: 100%; padding: 7px; font-size: 14px; }
#loginBox button { width: 100%; padding: 9px; font-size: 14px; background: var(--accent); color: #fff; border: 0; cursor: pointer; margin-top: 6px; }
#loginBox .warn { background: #fdecea; border: 1px solid #d33; padding: 8px; font-size: 12px; }
#loginBox .note { background: #fff8e1; border: 1px solid #e6c200; padding: 8px; font-size: 12px; }
#loginBox .hint { font-size: 11px; color: var(--muted); }
#loginBox .hidden { display: none; }
@media (max-width: 900px) {
  #palettes { width: 210px; }
  #tools { flex-direction: row; width: auto; height: 44px; overflow-x: auto; }
  #main { flex-direction: column; }
  #workspace { order: 1; }
  #palettes { order: 2; width: 100%; max-height: 40vh; }
}
