/* App shell (DeepL-style): sidebar with an icon-rail mode, popovers, main area; sections glossaries / saved. */

.shell.booting .sidebar, .shell.booting .main { visibility: hidden; }

/* ---------- sidebar ---------- */
.sidebar { padding: 14px 10px 8px; transition: width .18s ease, transform .2s; }
.sb-top { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 6px; margin-bottom: 12px; flex: none; }
.sb-logo { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; }
.sb-logo img { width: 30px; height: 30px; display: block; }
.sb-scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.nav .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* "My translations" group: caret up when open, children hang off a thin line under the icon */
.nav-caret { display: inline-flex; flex: none; }
.nav-caret svg { width: 18px !important; height: 18px !important; transform: rotate(180deg); transition: transform .15s; }
.nav-group[aria-expanded="false"] .nav-caret svg { transform: none; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 0 0 2px 21px; padding-left: 0; border-left: 1px solid var(--border-strong); }
.nav .sub { padding-left: 22px; min-height: 38px; margin-left: 2px; width: calc(100% - 2px); }
.nav-group[aria-expanded="false"].child-active { background: var(--accent-soft); color: var(--accent); }
.nav-group[aria-expanded="false"].child-active svg { color: var(--accent); }

/* not available yet */
.nav button.nav-soon { color: var(--text-2); }
.nav button.nav-soon svg { color: var(--text-2); }
.chip-soon {
  flex: none; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 700; color: var(--text-2); display: inline-flex; align-items: center;
}

.sb-bottom { flex: none; padding-top: 12px; }
.sb-notif .bell { position: relative; display: inline-flex; flex: none; }
.notif-dot { position: absolute; top: 0; right: 1px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.sb-sep { height: 1px; background: var(--border); margin: 8px 2px; flex: none; }

.sidebar .user-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 8px 8px 8px 6px; flex: none;
  border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left;
}
.sidebar .user-row:hover, .sidebar .user-row[aria-expanded="true"] { background: var(--surface-2); }
.sidebar .user-row .avatar { width: 32px; height: 32px; font-size: 14px; }
.sidebar .user-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.sidebar .user-meta b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .user-meta span { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ur-chev { display: inline-flex; flex: none; color: var(--text); }
.ur-chev svg { width: 18px; height: 18px; }

.sb-guest { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; flex: none; }
.sb-guest .btn { height: 40px; }
.sb-guest .btn:not(.btn-primary) { border-color: var(--text); }
.sb-guest-icon { display: none; }

.sb-foot { display: flex; justify-content: flex-end; padding: 2px 0 0; flex: none; }
.sb-collapse svg { width: 22px; height: 22px; }

/* ---------- icon rail (collapsed sidebar, desktop only) ---------- */
@media (min-width: 861px) {
  .shell.sb-collapsed .sidebar { width: var(--sidebar-rail); padding-left: 8px; padding-right: 8px; }
  .shell.sb-collapsed .sb-top { justify-content: center; padding: 0; }
  .shell.sb-collapsed .nav a, .shell.sb-collapsed .nav button.nav-item { justify-content: center; padding: 7px 0; gap: 0; }
  .shell.sb-collapsed .nav-label, .shell.sb-collapsed .nav-caret, .shell.sb-collapsed .chip-soon,
  .shell.sb-collapsed .nav-sub, .shell.sb-collapsed .user-meta, .shell.sb-collapsed .ur-chev { display: none !important; }
  .shell.sb-collapsed .nav-group.child-active { background: var(--accent-soft); border-color: var(--accent); }
  .shell.sb-collapsed .nav-group.child-active svg { color: var(--accent); }
  .shell.sb-collapsed .user-row { justify-content: center; padding: 8px 0; }
  .shell.sb-collapsed .sb-guest .btn { display: none; }
  .shell.sb-collapsed .sb-guest-icon { display: inline-flex; align-self: center; }
  .shell.sb-collapsed .sb-foot { justify-content: center; }
  .shell.sb-collapsed .sb-collapse svg { transform: scaleX(-1); }
}

/* ---------- popovers next to the sidebar ---------- */
.sb-pop { position: fixed; z-index: 80; }
.user-menu { padding: 6px; width: 280px; }
.user-menu svg { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.um-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.um-head > span:last-child { min-width: 0; }
.um-head b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-head b + span { display: block; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.sb-flyout { width: 220px; }
.sb-flyout .fly-head { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 6px 12px 4px; }
.sb-flyout a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.notif-pop {
  width: 360px; max-height: min(520px, calc(100vh - 16px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); overflow: hidden;
}
.np-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); font-size: 16px; }
.np-list { overflow-y: auto; padding: 6px; }
.np-item { display: flex; gap: 12px; padding: 10px; border-radius: 8px; color: var(--text) !important; text-decoration: none !important; position: relative; }
.np-item:hover { background: var(--surface-2); }
.np-item.unread::after { content: ""; position: absolute; right: 12px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.np-icon { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.np-icon svg { width: 18px; height: 18px; }
.np-icon.np-ok, .np-icon.np-welcome { background: var(--pro-soft); color: var(--pro); }
.np-icon.np-error { background: var(--danger-soft); color: var(--danger); }
.np-icon.np-plan { background: var(--warn-soft); color: #9a6a00; }
.np-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; padding-right: 14px; }
.np-body b { font-size: 14px; font-weight: 600; }
.np-body span { font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.np-body time { font-size: 12.5px; color: var(--muted); }
.np-empty { text-align: center; padding: 36px 16px 40px; color: var(--text-2); }
.np-empty svg { width: 36px; height: 36px; color: var(--border-strong); }
.np-empty p { margin: 6px 0 0; }

/* ---------- main area: white band on top, grey work area ---------- */
.main { background: var(--bg); display: flex; flex-direction: column; }
.main-band {
  height: 64px; flex: none; background: var(--surface); display: flex; align-items: center; gap: 8px; padding: 0 16px;
}
.main-body { flex: 1; padding: 24px 24px 56px; min-width: 0; }
.section { max-width: 1100px; margin: 0 auto; }
.section.section-wide { max-width: none; }
.sidebar-back { display: none; }

/* ---------- section headers ---------- */
.sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-head .page-title { margin-bottom: 4px; }
.sec-lead { margin: 0; color: var(--text-2); }
.sec-usage { padding-top: 8px; font-size: 14px; color: var(--text-2); }
.sec-subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 28px 0 10px; }
.sec-subhead h2 { font-size: 18px; margin: 0; }
.sec-subhead .muted { font-size: 14px; }
.loading-card { display: flex; align-items: center; gap: 10px; padding: 22px; color: var(--text-2); }
.spinner-light { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.empty .btn { margin-top: 10px; }
.empty .btn svg { width: 20px; height: 20px; margin: 0; color: inherit; }
.empty p { color: var(--text-2); max-width: 460px; margin: 0 auto; }

/* language field (button that opens the language picker) */
.lang-field {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 44px; padding: 0 12px 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; text-align: left;
}
.lang-field span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-field svg { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.lang-field:hover { border-color: var(--text-2); }
.lang-field[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lang-field.empty span { color: var(--muted); }
.fo-arrow { margin-bottom: 4px; }

/* ---------- glossaries ---------- */
.gl-limits { font-size: 14px; color: var(--text-2); margin: -4px 0 16px; }
.gl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.gl-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 16px 18px; cursor: pointer; transition: border-color .15s, box-shadow .15s; outline: none; }
.gl-card:hover, .gl-card:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gl-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.gl-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--pro-soft); color: var(--pro); display: inline-flex; align-items: center; justify-content: center; }
.gl-icon svg { width: 20px; height: 20px; }
.gl-actions { display: inline-flex; gap: 2px; }
.gl-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-pair { color: var(--text-2); font-size: 14px; }
.gl-count { color: var(--muted); font-size: 13px; }

.modal.modal-wide { max-width: 720px; }
.gl-langs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.gl-langs .fo-arrow { margin-bottom: 20px; }
.gl-entries-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 8px; }
.gl-entry-count { font-size: 13px; font-variant-numeric: tabular-nums; }
.gl-entry-count.over { color: var(--danger); font-weight: 700; }
.gl-cols, .gl-row { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 8px; align-items: center; }
.gl-cols { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.gl-rows { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; padding: 2px; }
.gl-row .input { height: 40px; }
.gl-row-actions { display: flex; gap: 8px; margin-top: 10px; }
.gl-paste { margin-top: 10px; }
.gl-paste-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.gl-paste-actions .hint { font-size: 13px; color: var(--text-2); }
.gl-form .form-error { margin: 12px 0 0; }

/* ---------- saved ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px; width: min(360px, 100%); height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.search-box input { border: 0; outline: none; flex: 1; min-width: 0; height: 100%; background: transparent; }
.sv-count { font-size: 14px; color: var(--text-2); margin-bottom: 10px; }
.sv-item { margin-bottom: 12px; overflow: hidden; }
.sv-item header { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.sv-pair { font-weight: 650; font-size: 14px; }
.sv-date { font-size: 13px; color: var(--text-2); flex: 1; }
.sv-actions { display: inline-flex; gap: 2px; }
.sv-body { display: grid; grid-template-columns: 1fr 1fr; }
.sv-body p { margin: 0; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; }
.sv-tgt { border-left: 1px solid var(--border); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell.nav-open .sidebar-back { display: block; position: fixed; inset: 0; background: rgba(15, 27, 45, .4); z-index: 65; }
  .sidebar { width: min(var(--sidebar-w), 86vw); }
  .sb-foot, .sidebar > .sb-sep:nth-last-child(2) { display: none; }
  .main-band { height: 56px; padding: 0 8px; border-bottom: 1px solid var(--border); }
  .main-band .brand { font-size: 17px; }
  .main-body { padding: 16px 16px 48px; }
  .notif-pop { width: min(340px, calc(100vw - 16px)); }
}
@media (max-width: 640px) {
  .sv-body { grid-template-columns: 1fr; }
  .sv-tgt { border-left: 0; border-top: 1px solid var(--border); }
  .sv-date { display: none; }
  .gl-langs { grid-template-columns: 1fr; }
  .gl-langs .fo-arrow { display: none; }
  .gl-langs .field { margin-bottom: 8px; }
  .search-box { width: 100%; }
}
