/* AICE Documents - additions (generated colour classes + new screens) */

/* ---- more tag / correspondent colours ---- */
.tag-blue { background: #dbeafe; color: #1d4ed8; }
.tag-sky { background: #e0f2fe; color: #0369a1; }
.tag-cyan { background: #cffafe; color: #0e7490; }
.tag-teal { background: #ccfbf1; color: #0f766e; }
.tag-green { background: #d1fae5; color: #047857; }
.tag-lime { background: #ecfccb; color: #4d7c0f; }
.tag-yellow { background: #fef9c3; color: #a16207; }
.tag-amber { background: #fef3c7; color: #b45309; }
.tag-orange { background: #ffedd5; color: #c2410c; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-rose { background: #ffe4e6; color: #be123c; }
.tag-pink { background: #fce7f3; color: #be185d; }
.tag-fuchsia { background: #fae8ff; color: #a21caf; }
.tag-purple { background: #ede9fe; color: #6d28d9; }
.tag-violet { background: #ddd6fe; color: #5b21b6; }
.tag-indigo { background: #e0e7ff; color: #4338ca; }
.tag-brown { background: #efe6dd; color: #7c4a21; }
.tag-gray { background: #f3f4f6; color: #374151; }
.tag-slate { background: #e2e8f0; color: #334155; }
.correspondent-label.correspondent-blue { color: #1d4ed8; }
.correspondent-label.correspondent-sky { color: #0369a1; }
.correspondent-label.correspondent-cyan { color: #0e7490; }
.correspondent-label.correspondent-teal { color: #0f766e; }
.correspondent-label.correspondent-green { color: #047857; }
.correspondent-label.correspondent-lime { color: #4d7c0f; }
.correspondent-label.correspondent-yellow { color: #a16207; }
.correspondent-label.correspondent-amber { color: #b45309; }
.correspondent-label.correspondent-orange { color: #c2410c; }
.correspondent-label.correspondent-red { color: #b91c1c; }
.correspondent-label.correspondent-rose { color: #be123c; }
.correspondent-label.correspondent-pink { color: #be185d; }
.correspondent-label.correspondent-fuchsia { color: #a21caf; }
.correspondent-label.correspondent-purple { color: #6d28d9; }
.correspondent-label.correspondent-violet { color: #5b21b6; }
.correspondent-label.correspondent-indigo { color: #4338ca; }
.correspondent-label.correspondent-brown { color: #7c4a21; }
.correspondent-label.correspondent-gray { color: #374151; }
.correspondent-label.correspondent-slate { color: #334155; }

.tag-swatch-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-swatch-picker .tag { border: 2px solid transparent; cursor: pointer; margin-right: 0; }
.tag-swatch-picker .tag.selected { border-color: var(--text-primary); }

/* ---- branding / header ---- */
.brand-logo-img { max-height: 34px; max-width: 150px; object-fit: contain; }
.user-avatar-initials {
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-blue-light); color: var(--brand-blue); font-size: 12px; font-weight: 700;
}
.user-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 130; min-width: 210px;
  background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px; cursor: default;
}
.user-menu.open { display: block; }
.user-menu-email { padding: 8px 10px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); margin-bottom: 4px; }

/* ---- sign-in page ---- */
.login-wrap { min-height: calc(100vh / var(--zv, 1)); display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg-gray); }
.login-card {
  width: 380px; max-width: 100%; background: var(--bg-white); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 32px;
}
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.login-brand img { max-height: 48px; max-width: 220px; object-fit: contain; }
.login-error { background: var(--danger-bg); color: #b91c1c; border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.login-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; }

/* ---- admin pages ---- */
.section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin: 16px 0; }
.section-tab { padding: 9px 16px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.section-tab.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); padding: 8px 10px; border-bottom: 1px solid var(--border-color); }
.admin-table td { padding: 11px 10px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; margin-right: 4px; }
.pill-admin { background: var(--purple-bg); color: #6d28d9; }
.pill-active { background: var(--success-bg); color: #047857; }
.pill-off { background: var(--danger-bg); color: #b91c1c; }
.pill-group { background: var(--brand-blue-light); color: var(--brand-blue); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 4px 0 6px; display: block; }
.hint { font-size: 12px; color: var(--text-muted); }
.check-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border-color); font-size: 13px; cursor: pointer; }
.check-row:last-child { border-bottom: none; }
.settings-block { margin-bottom: 20px; }
.logo-preview { width: 220px; height: 96px; border: 1px dashed var(--border-color-strong); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; background: var(--bg-gray); overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--text-faint); }
.status-dot.ok { background: var(--success); }
.status-dot.bad { background: var(--danger); }

/* ---- logs ---- */
.log-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #0f172a; color: #e2e8f0; border-radius: var(--radius-md); padding: 6px 0; max-height: calc(100vh / var(--zv, 1) - 290px); overflow: auto; }
.log-line { display: grid; grid-template-columns: 150px 70px 150px 1fr; gap: 10px; padding: 3px 14px; white-space: pre-wrap; word-break: break-word; }
.log-line:hover { background: rgba(255,255,255,.05); }
.log-ts { color: #94a3b8; }
.log-name { color: #7dd3fc; overflow: hidden; text-overflow: ellipsis; }
.log-WARNING .log-level { color: #fbbf24; } .log-ERROR .log-level, .log-CRITICAL .log-level { color: #f87171; }
.log-INFO .log-level { color: #4ade80; } .log-DEBUG .log-level { color: #94a3b8; }

/* ---- sharing dialog ---- */
.share-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.share-row:last-child { border-bottom: none; }
.share-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-blue-light); color: var(--brand-blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.share-who { flex: 1; min-width: 0; }
.share-who small { display: block; color: var(--text-muted); font-size: 12px; }
.view-only-note { font-size: 11px; color: var(--text-muted); background: var(--bg-gray); border-radius: 10px; padding: 1px 8px; margin-left: 6px; }

/* ---- shared badges and the selection bar ---- */
.shared-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--brand-blue-light); color: var(--brand-blue); border: none; cursor: pointer; vertical-align: middle; }
.shared-badge.incoming { background: var(--bg-gray); color: var(--text-muted); cursor: default; font-weight: 500; }
.selection-bar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 900; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--bg-white); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); font-size: 14px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px); width: max-content; }

/* ---- mobile ---- */
.menu-btn { display: none; flex-shrink: 0; }
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidebar { width: min(300px, 85vw); box-shadow: var(--shadow-lg); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 49; }
  .top-header { padding: 10px 12px; gap: 8px; }
  .search-box { max-width: none; min-width: 0; }
  .search-box > span { display: none; }
  .header-actions { gap: 2px; flex-shrink: 0; }
  .user-info, .user-profile > svg { display: none; }
  .content-area { padding: 16px 12px 90px; }
  .page-title { font-size: 20px; }
  .toolbar-left, .toolbar-right { flex-wrap: wrap; }
  .doc-table-container, .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .doc-table { min-width: 560px; }
  .doc-table th:nth-child(4), .doc-table td:nth-child(4),
  .doc-table th:nth-child(6), .doc-table td:nth-child(6) { display: none; }
  .quick-access-grid { grid-template-columns: repeat(2, 1fr); }
  .preview-panel.open { width: 100vw; max-width: 100vw; }
  .modal { max-width: 94vw !important; }
  .selection-bar { bottom: 12px; padding: 8px 10px; gap: 6px; }
  .notif-box { right: 8px !important; left: 8px; width: auto !important; }
  .admin-table { display: block; overflow-x: auto; }
  .log-line { grid-template-columns: 1fr; gap: 0; }
  .share-row { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .quick-access-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .btn { padding: 9px 12px; }
}

/* ---- notifications ---- */
.notif-box { position: fixed; top: 58px; right: 70px; width: 360px; max-height: 70vh; overflow-y: auto; background: var(--bg-white); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 120; }
.notif-head { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--border-color); }
.notif-item { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border-color); color: inherit; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-gray); }
.notif-item.unread { background: var(--brand-blue-light); }
.notif-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-blue-light); color: var(--brand-blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-text { min-width: 0; }
.notif-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-sub { font-size: 12px; color: var(--text-muted); }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); }

/* ---- help ---- */
.help-body h4 { margin: 14px 0 4px; font-size: 13px; }
.help-body h4:first-child { margin-top: 0; }
.help-body ul { margin: 0; padding-left: 18px; color: var(--text-secondary); line-height: 1.55; }

/* ---- scanner ---- */
.scan-pages { display: flex; gap: 8px; flex-wrap: wrap; min-height: 40px; }
.scan-thumb { position: relative; width: 84px; height: 112px; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: var(--bg-gray); }
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scan-thumb span { position: absolute; left: 4px; bottom: 4px; background: rgba(17,24,39,.75); color: #fff; font-size: 11px; border-radius: 8px; padding: 0 6px; }
.scan-thumb button { position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(17,24,39,.75); color: #fff; font-size: 15px; line-height: 1; }

/* ---- dark mode ---- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --text-primary: #f3f4f6; --text-secondary: #d1d5db; --text-muted: #9ca3af; --text-faint: #6b7280;
  --bg-white: #1a2233; --bg-gray: #0f1623; --bg-sidebar: #151d2c;
  --border-color: #2a3447; --border-color-strong: #3a465c;
  --brand-blue-light: #1e2b4a;
  --success-bg: #123b2d; --warning-bg: #3f3210; --danger-bg: #4a1d1d; --purple-bg: #2e2250;
  --tag-blue-bg: #1e2b4a; --tag-blue-text: #93c5fd; --tag-green-bg: #123b2d; --tag-green-text: #6ee7b7;
  --tag-purple-bg: #2e2250; --tag-purple-text: #c4b5fd; --tag-orange-bg: #3f2a12; --tag-orange-text: #fdba74;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 4px 12px rgba(0,0,0,.5); --shadow-lg: 0 10px 30px rgba(0,0,0,.6);
}
:root[data-theme="dark"] body { background: var(--bg-gray); color: var(--text-primary); }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--bg-gray); color: var(--text-primary); border-color: var(--border-color-strong); }
:root[data-theme="dark"] .brand-logo { color: var(--text-primary); }
:root[data-theme="dark"] .btn-primary { color: #fff; }
:root[data-theme="dark"] .log-box { background: #0a0f1a; }

/* ---- folder picker tree (New folder) ---- */
.pp-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-gray); padding: 4px; }
.pp-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.pp-row:hover { background: var(--bg-white); }
.pp-row.selected { background: var(--brand-blue-light); color: var(--brand-blue); font-weight: 600; }
.pp-toggle { width: 20px; height: 20px; border: none; background: transparent; color: var(--text-muted); padding: 0; font-size: 12px; flex-shrink: 0; }
.pp-spacer { width: 20px; flex-shrink: 0; }
.pp-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.pp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-chosen { margin-top: 6px; }

/* ---- phones: keep the selection bar on screen ---- */
@media (max-width: 900px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .selection-bar { left: 8px; right: 8px; bottom: 10px; transform: none; max-width: none; width: auto; }
  .sel-count { flex-basis: 100%; text-align: center; }
  .sel-actions { flex: 1 1 100%; }
  .selection-bar .btn { flex: 1 1 auto; justify-content: center; }
}

#selectionBarLegacy { display: none !important; }
.sel-count { white-space: nowrap; font-weight: 500; }
.sel-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---- offline tree ---- */
.off-row { display: flex; align-items: center; gap: 8px; padding-top: 8px; padding-bottom: 8px; padding-right: 12px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.off-folder { cursor: pointer; font-weight: 600; }
.off-folder:hover { background: var(--bg-gray); }
.off-arrow { width: 14px; flex-shrink: 0; color: var(--text-muted); font-size: 12px; }
.off-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.off-doc .off-name { font-weight: 400; }

/* ---- expiry ---- */
.expiry-badge { font-weight: 600; }
.expiry-badge.expired { background: var(--danger-bg); color: var(--danger); }
.expiry-badge.soon { background: var(--warning-bg); color: #b45309; }
.expiry-badge.later { background: var(--bg-gray); color: var(--text-muted); font-weight: 500; }
.notif-item.overdue .notif-icon { background: var(--danger-bg); color: var(--danger); }
.notif-item.due .notif-icon { background: var(--warning-bg); color: #b45309; }

/* PowerPoint icon */
.file-icon.pptx { background: #f97316; }

/* scanner page editor */
.scan-thumb { position: relative; cursor: pointer; }
.scan-thumb .scan-mv { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 2px; }
.scan-thumb .scan-mv button { background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 4px; font-size: 11px; padding: 2px 6px; cursor: pointer; }
.crop-wrap { position: relative; width: 100%; max-height: 55vh; background: #1f2937; border-radius: 8px; overflow: hidden; touch-action: none; user-select: none; display: flex; justify-content: center; }
.crop-wrap { display: block; width: fit-content; max-width: 100%; margin: 0 auto; }
.crop-wrap img { display: block; max-width: 100%; max-height: 55vh; }
.crop-box { position: absolute; border: 2px solid #2563eb; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); cursor: move; touch-action: none; }
.crop-handle { position: absolute; width: 22px; height: 22px; background: #2563eb; border: 2px solid #fff; border-radius: 50%; touch-action: none; }
.crop-handle[data-h="nw"] { left: -11px; top: -11px; cursor: nwse-resize; } .crop-handle[data-h="ne"] { right: -11px; top: -11px; cursor: nesw-resize; }
.crop-handle[data-h="sw"] { left: -11px; bottom: -11px; cursor: nesw-resize; } .crop-handle[data-h="se"] { right: -11px; bottom: -11px; cursor: nwse-resize; }
.se-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { border: 1px solid var(--border); background: var(--bg-white, #fff); color: inherit; border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--brand-blue, #2563eb); color: #fff; border-color: var(--brand-blue, #2563eb); }

/* search highlighting */
.doc-snippet { font-size: 12px; color: var(--text-muted, #6b7280); margin-top: 2px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark.hit { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---- file type icons: page with a folded corner, a type colour and a short label ---- */
.file-icon { position: relative; font-size: 0 !important; border-radius: 5px; overflow: hidden;
  box-shadow: inset 0 -10px 14px -8px rgba(0,0,0,.28); }
.file-icon::before { content: ""; position: absolute; top: 0; right: 0; width: 28%; height: 28%;
  background: linear-gradient(225deg, rgba(255,255,255,.95) 50%, rgba(0,0,0,.22) 50%); border-bottom-left-radius: 3px; }
.file-icon::after { font-size: 9.5px; font-weight: 800; letter-spacing: .02em; color: #fff; position: relative; top: 3px; }
.file-icon.pdf  { background: linear-gradient(160deg, #f87171, #dc2626); }
.file-icon.docx { background: linear-gradient(160deg, #3b82f6, #1d4ed8); }
.file-icon.xlsx { background: linear-gradient(160deg, #34d399, #047857); }
.file-icon.pptx { background: linear-gradient(160deg, #fb923c, #c2410c); }
.file-icon.image { background: linear-gradient(160deg, #a78bfa, #6d28d9); }
.file-icon.default { background: linear-gradient(160deg, #9ca3af, #4b5563); }
.file-icon.pdf::after { content: "PDF"; }
.file-icon.docx::after { content: "DOC"; }
.file-icon.xlsx::after { content: "XLS"; }
.file-icon.pptx::after { content: "PPT"; }
.file-icon.image::after { content: "IMG"; }
.file-icon.default::after { content: "FILE"; }
