/*
CADLex application styling.
Loaded after turtlestack.css and overrides its page-level defaults.
Palette follows the Turtlestack brand: navy #2b4b80, slate #506a94, amber #e6a91f.
*/

:root {
  --cx-navy: #2b4b80;
  --cx-navy-deep: #1f3760;
  --cx-slate: #506a94;
  --cx-amber: #e6a91f;
  --cx-amber-dark: #c98f0e;
  --cx-ink: #2d3340;
  --cx-muted: #6b7280;
  --cx-line: #dfe4ec;
  --cx-paper: #ffffff;
  --cx-canvas: #eef1f6;
  --cx-danger: #c0392b;
  --cx-success: #2e8b57;
  --cx-radius: 12px;
  --cx-shadow: 0 1px 2px rgba(31, 55, 96, 0.06), 0 8px 24px rgba(31, 55, 96, 0.08);
}

html { height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  font-family: "Josefin Sans", "Segoe UI", Arial, sans-serif;
  font-weight: 400;
  color: var(--cx-ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(80, 106, 148, 0.18), transparent 60%),
    radial-gradient(900px 300px at 95% 0%, rgba(230, 169, 31, 0.12), transparent 60%),
    var(--cx-canvas);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cx-slate); font-weight: 400; text-align: inherit; }
a:hover { color: var(--cx-navy); text-decoration: none; }

h1, h2, h3, h4, h5, h6 { color: var(--cx-ink); font-family: "Josefin Sans", sans-serif; }
p { font-family: "Josefin Sans", sans-serif; color: var(--cx-muted); font-size: 1rem; line-height: 1.5; }

/* ---------- Top bar ---------- */

.cx-topbar {
  background: linear-gradient(90deg, var(--cx-navy-deep), var(--cx-navy) 55%, var(--cx-slate));
  color: #fafafa;
  box-shadow: 0 2px 12px rgba(31, 55, 96, 0.35);
  position: sticky;
  top: 0;
  z-index: 50;
}

.cx-topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cx-brand img { height: 40px; width: auto; display: block; }

.cx-topbar-right { display: flex; align-items: center; gap: 1rem; }

.cx-org {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: rgba(250, 250, 250, 0.9);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}

.cx-org .fa { color: var(--cx-amber); margin-right: 0.35rem; }

/* ---------- Page frame ---------- */

.cx-page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.cx-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.cx-page-head h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.cx-page-head p { margin: 0; }

.cx-crumb {
  font-size: 0.85rem;
  color: var(--cx-muted);
  margin-bottom: 0.4rem;
}
.cx-crumb a { color: var(--cx-slate); }
.cx-crumb .fa { font-size: 0.7rem; margin: 0 0.4rem; opacity: 0.6; }

.cx-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 860px) {
  .cx-layout { grid-template-columns: 1fr; }
  .cx-side { position: static !important; }
}

.cx-side { position: sticky; top: 80px; }

/* ---------- Cards ---------- */

.cx-card {
  background: var(--cx-paper);
  border: 1px solid var(--cx-line);
  border-radius: var(--cx-radius);
  box-shadow: var(--cx-shadow);
  overflow: hidden;
}

.cx-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--cx-line);
  background: linear-gradient(180deg, #fbfcfe, #f4f6fa);
}

.cx-card-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.cx-card-body { padding: 1.25rem; }

.cx-card-foot {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--cx-line);
  background: #f7f9fc;
  font-size: 0.85rem;
  color: var(--cx-muted);
}

.cx-tag {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  background: var(--cx-line);
  color: var(--cx-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cx-count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  background: var(--cx-navy);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
}
.cx-count.is-amber { background: var(--cx-amber); color: var(--cx-navy-deep); }
.cx-count.is-zero { background: var(--cx-line); color: var(--cx-muted); }

/* ---------- Buttons ---------- */

.cx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: "Josefin Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.cx-btn:active { transform: translateY(1px); }
.cx-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(80, 106, 148, 0.3); }
.cx-btn .fa { font-size: 1em; }
.cx-btn-block { width: 100%; }

.cx-btn-primary {
  background: var(--cx-amber);
  color: var(--cx-navy-deep);
  box-shadow: 0 2px 6px rgba(230, 169, 31, 0.35);
}
.cx-btn-primary:hover { background: var(--cx-amber-dark); color: var(--cx-navy-deep); }

.cx-btn-navy { background: var(--cx-navy); color: #fff; }
.cx-btn-navy:hover { background: var(--cx-navy-deep); color: #fff; }

.cx-btn-outline {
  background: #fff;
  color: var(--cx-navy);
  border-color: var(--cx-line);
}
.cx-btn-outline:hover { border-color: var(--cx-slate); color: var(--cx-navy); background: #f7f9fc; }

.cx-btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fafafa;
  border-color: rgba(255, 255, 255, 0.25);
  padding: 0.45rem 0.9rem;
}
.cx-btn-ghost:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.cx-btn-danger { background: #fff; color: var(--cx-danger); border-color: #f0c9c4; }
.cx-btn-danger:hover { background: var(--cx-danger); color: #fff; border-color: var(--cx-danger); }

.cx-btn-icon { padding: 0.45rem 0.6rem; }

.cx-actions { display: flex; flex-direction: column; gap: 0.6rem; }
.cx-actions-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Bootstrap modal buttons on the confirm dialogs */
.modal .btn-warning { background: var(--cx-amber); border-color: var(--cx-amber); color: var(--cx-navy-deep); font-weight: 600; }
.modal .btn-warning:hover { background: var(--cx-amber-dark); border-color: var(--cx-amber-dark); color: var(--cx-navy-deep); }
.modal .btn-secondary { background: #fff; color: var(--cx-navy); border-color: var(--cx-line); }
.modal .btn-secondary:hover { background: #f7f9fc; color: var(--cx-navy); border-color: var(--cx-slate); }
.modal-content { border: 0; border-radius: var(--cx-radius); box-shadow: 0 24px 60px rgba(31, 55, 96, 0.35); color: var(--cx-ink); }
.modal-header { border-bottom-color: var(--cx-line); }
.modal-footer { border-top-color: var(--cx-line); }
.modal-title { font-weight: 600; font-size: 1.1rem; color: var(--cx-ink); }
.modal-body p { color: var(--cx-ink); }

/* ---------- Forms ---------- */

.cx-field { margin-bottom: 1.1rem; }
.cx-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cx-muted);
  margin-bottom: 0.4rem;
}

.cx-input-wrap { position: relative; }
.cx-input-wrap .fa {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cx-muted);
  pointer-events: none;
}

.cx-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--cx-line);
  border-radius: 8px;
  background: #fff;
  color: var(--cx-ink);
  font-family: "Josefin Sans", sans-serif;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cx-input-wrap .cx-input { padding-left: 2.4rem; }
.cx-input::placeholder { color: #a9b0bd; }
.cx-input:focus {
  outline: none;
  border-color: var(--cx-slate);
  box-shadow: 0 0 0 3px rgba(80, 106, 148, 0.18);
}

.cx-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .cx-form-grid { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */

.cx-table-wrap { overflow-x: auto; }

.cx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

.cx-table th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cx-muted);
  background: #f7f9fc;
  border-bottom: 1px solid var(--cx-line);
  padding: 0.7rem 1rem;
  text-align: left;
  vertical-align: middle;
  line-height: 1.3;
}

.cx-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: middle;
  color: var(--cx-ink);
}

.cx-table tbody tr:last-child td { border-bottom: 0; }
.cx-table tbody tr:hover td { background: #f8fafd; }
.cx-table tbody tr:has(.is-keep .hidden-checkbox:checked) td { background: rgba(46, 139, 87, 0.07); }
.cx-table tbody tr:has(.is-reject .hidden-checkbox:checked) td { background: rgba(192, 57, 43, 0.06); }
.cx-table tbody tr:has(.is-keep .hidden-checkbox:checked) .cx-table .cx-col-actions { width: 70px; text-align: right; }

.cx-word { color: var(--cx-success); font-weight: 600; }
.cx-table tbody tr:has(.is-reject .hidden-checkbox:checked) .cx-table .cx-col-actions { width: 70px; text-align: right; }

.cx-word { color: var(--cx-danger); font-weight: 600; text-decoration: line-through; text-decoration-color: rgba(192, 57, 43, 0.5); }

.cx-table .cx-col-check { width: 90px; text-align: center; }
.cx-table td.cx-col-check { text-align: center; }
.cx-table th.cx-col-check .fa { display: block; font-size: 1rem; margin-bottom: 0.2rem; color: var(--cx-slate); }

.cx-table .cx-col-actions { width: 70px; text-align: right; }

.cx-word { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 0.95rem; color: var(--cx-ink); }
.cx-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 0.9rem; }

.cx-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--cx-muted);
}
.cx-empty .fa { font-size: 2rem; display: block; margin-bottom: 0.5rem; opacity: 0.4; }

/* Checkbox toggles: hide the native input, render a tile around the FA icons */
.fa-icon-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  border-radius: 8px;
  border: 1px solid var(--cx-line);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, transform 0.08s ease;
}
.fa-icon-checkbox:hover { border-color: var(--cx-slate); transform: translateY(-1px); }
.fa-icon-checkbox .fa { font-size: 1.05rem; }
/* Unchecked: an empty box. Checked: the action icon (bin / book) in its colour. */
.fa-icon-checkbox .cx-off { color: transparent; }
.fa-icon-checkbox .cx-on { display: none; }
.hidden-checkbox:checked ~ .cx-off { display: none; }
.hidden-checkbox:checked ~ .cx-on { display: inline; }
.fa-icon-checkbox.is-reject .cx-on { color: var(--cx-danger); }
.fa-icon-checkbox.is-keep .cx-on { color: var(--cx-success); }
.fa-icon-checkbox.is-reject:has(.hidden-checkbox:checked) { border-color: var(--cx-danger); background: rgba(192, 57, 43, 0.08); }
.fa-icon-checkbox.is-keep:has(.hidden-checkbox:checked) { border-color: var(--cx-success); background: rgba(46, 139, 87, 0.08); }

/* ---------- Toolbar above tables ---------- */

.cx-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--cx-line);
  background: #fff;
}
.cx-toolbar .cx-input-wrap { flex: 1; max-width: 380px; }
.cx-toolbar .cx-input { padding-top: 0.55rem; padding-bottom: 0.55rem; }
.cx-toolbar-meta { font-size: 0.85rem; color: var(--cx-muted); white-space: nowrap; }

/* ---------- Menu tiles ---------- */

.cx-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.cx-tile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.4rem 1.4rem 1.2rem;
  background: var(--cx-paper);
  border: 1px solid var(--cx-line);
  border-radius: var(--cx-radius);
  box-shadow: var(--cx-shadow);
  color: var(--cx-ink);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.cx-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(80, 106, 148, 0.5);
  box-shadow: 0 4px 6px rgba(31, 55, 96, 0.06), 0 16px 36px rgba(31, 55, 96, 0.14);
  color: var(--cx-ink);
}

.cx-tile-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: linear-gradient(135deg, rgba(43, 75, 128, 0.12), rgba(80, 106, 148, 0.22));
  color: var(--cx-navy);
}
.cx-tile-icon.is-amber { background: linear-gradient(135deg, rgba(230, 169, 31, 0.2), rgba(230, 169, 31, 0.4)); color: #8a6208; }

.cx-tile h3 { font-size: 1.1rem; font-weight: 600; margin: 0; color: var(--cx-ink); }
.cx-tile p { margin: 0; font-size: 0.92rem; }
.cx-tile .cx-tile-go {
  margin-top: auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cx-slate);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.cx-tile:hover .cx-tile-go { color: var(--cx-navy); }
.cx-tile-badge { position: absolute; top: 1rem; right: 1rem; }

.cx-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cx-muted);
  margin: 2rem 0 0.9rem;
}
.cx-section-label:first-child { margin-top: 0; }

/* ---------- Login ---------- */

.cx-login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(230, 169, 31, 0.18), transparent 60%),
    radial-gradient(800px 500px at 80% 90%, rgba(80, 106, 148, 0.6), transparent 60%),
    linear-gradient(160deg, var(--cx-navy-deep), var(--cx-navy) 60%, var(--cx-slate));
}

.cx-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--cx-paper);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.cx-login-brand {
  background: linear-gradient(90deg, var(--cx-navy-deep), var(--cx-navy));
  padding: 1.75rem 2rem 1.5rem;
  text-align: center;
}
.cx-login-brand img { height: 56px; width: auto; }
.cx-login-brand p { margin: 0.75rem 0 0; color: rgba(250, 250, 250, 0.75); font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; }

.cx-login-body { padding: 1.75rem 2rem 2rem; }
.cx-login-body h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 1.25rem; }

.cx-login-foot { text-align: center; margin-top: 1.25rem; font-size: 0.8rem; color: var(--cx-muted); }
.cx-login-foot a { color: var(--cx-slate); }

/* ---------- Misc ---------- */

.cx-note {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  background: rgba(230, 169, 31, 0.12);
  border: 1px solid rgba(230, 169, 31, 0.45);
  color: #6b4d06;
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}
.cx-note .fa { margin-top: 0.15rem; }

.cx-kv { display: grid; grid-template-columns: 160px 1fr; gap: 0.5rem 1rem; margin: 0; }
.cx-kv dt { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cx-muted); align-self: center; }
.cx-kv dd { margin: 0; }

.cx-key {
  display: inline-block;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: #f4f6fa;
  border: 1px dashed var(--cx-slate);
  font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  font-size: 0.95rem;
  color: var(--cx-navy);
  word-break: break-all;
}

.cx-stack { margin-bottom: 1.5rem; }
.cx-hint { margin-bottom: 1rem; }

.cx-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--cx-muted);
  margin-top: 3rem;
}
.cx-footer a { color: var(--cx-slate); }
