/* GlobalDigital · RMCMP — shared theme for Admin + Manager panels. */
:root {
  --bg: #0e0b14;
  --panel: #181221;
  --panel-2: #1f1830;
  --border: #2c2440;
  --accent: #c68cff;
  --accent-2: #643399;
  --accent-grad: linear-gradient(135deg, #c68cff 0%, #643399 100%);
  --text: #ece8f5;
  --muted: #9b91b3;
  --ok: #4ade80;
  --off: #5a516e;
  --danger: #ff6b8a;
  --warn: #fbbf24;
  --info: #60a5fa;
  --radius: 14px;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #2a1b40 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
button {
  font-family: inherit;
  cursor: pointer;
}
h1,
h2,
h3 {
  font-weight: 800;
}

/* Header / nav */
header.app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(24, 18, 33, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.logo .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #fff;
}
/* White-label logo: a wide brand mark (e.g. 10:3) must not be crushed into the
   30×30 badge. When .mark holds an <img>, drop the fixed square and size the
   image to its own aspect at the header height. */
.logo .mark:has(img) {
  width: auto;
  min-width: 30px;
  max-width: 200px;
  background: transparent !important;
  border-radius: 0;
}
.logo .mark img {
  width: auto !important;
  height: 30px !important;
  max-width: 100%;
}
.logo .name {
  font-size: 16px;
}
.logo .name b {
  color: var(--accent);
}
.logo .sub {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  margin-left: 4px;
}
nav.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
nav.tabs a {
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 13px;
  border-radius: 9px;
  transition: 0.15s;
}
nav.tabs a:hover {
  color: var(--text);
  background: var(--panel-2);
}
nav.tabs a.active {
  color: #fff;
  background: var(--panel-2);
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 18px 70px;
}
/* Wide layout for the constructor: each .cols column ≈ half the viewport. */
main#view.wide {
  max-width: min(1640px, 94vw);
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn:hover {
  border-color: var(--accent);
}
.btn.primary {
  background: var(--accent-grad);
  border: none;
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  color: var(--danger);
  border-color: #533;
}
.btn.danger:hover {
  background: rgba(255, 107, 138, 0.1);
  border-color: var(--danger);
}
.btn.sm {
  padding: 6px 11px;
  font-size: 13px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Cards / layout */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}
.section-head h2 {
  font-size: 19px;
  margin: 0;
}
.muted {
  color: var(--muted);
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Stat cards */
.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 24px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .v {
  font-size: 28px;
  font-weight: 800;
}
.stat .l {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Forms */
label.field {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 7px;
}
.req {
  color: #ff6b6b;
  font-weight: 700;
} /* required-field marker (next to a label) */
/* invalid cue only AFTER the user interacts/submits (:user-invalid never matches a
   pristine field, so empty required inputs aren't red on first render) */
input:user-invalid,
input.invalid {
  border-color: #ff6b6b;
}
input[type='text'],
input[type='password'],
input[type='url'],
input[type='email'],
input[type='number'],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198, 140, 255, 0.15);
}
/* Keyboard-only focus ring for buttons / links / nav / the focused main view.
   :focus-visible keeps mouse clicks clean while making Tab navigation visible. */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
[role='dialog']:focus-visible,
label.switch:focus-within,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
#view:focus,
#view:focus-visible {
  outline: none;
} /* programmatic focus target — no ring on the whole pane */
input[type='color'] {
  width: 46px;
  height: 40px;
  padding: 3px;
  cursor: pointer;
}
.form-row {
  margin-bottom: 15px;
}
.msg {
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}
.msg.error {
  color: var(--danger);
}
.msg.ok {
  color: var(--ok);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}
.tablecard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th,
td {
  text-align: left;
  padding: 13px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr.clickable {
  cursor: pointer;
}
tbody tr.clickable:hover {
  background: var(--panel-2);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.badge.draft {
  color: var(--muted);
}
.badge.sent {
  color: var(--info);
  border-color: #2b3a55;
}
.badge.approved {
  color: var(--ok);
  border-color: #244e35;
}
.badge.rejected {
  color: var(--danger);
  border-color: #533;
}

/* Toggle switch */
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 46px;
  display: inline-block;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--off);
  transition: 0.2s;
  cursor: pointer;
}
.slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider {
  background: var(--accent-grad);
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
}
.switch input:disabled + .slider {
  opacity: 0.6;
  cursor: wait;
}

/* Modal + drawer */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 18px;
}
.modal {
  width: 100%;
  max-width: 460px;
}
.drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.drawer-wrap .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 22px;
  overflow-y: auto;
}

/* Login */
.login-wrap {
  min-height: 76vh;
  display: grid;
  place-items: center;
}
.login-card {
  width: 100%;
  max-width: 380px;
}

/* Misc */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 60;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.err {
  border-color: var(--danger);
  color: var(--danger);
}
.hidden {
  display: none !important;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
.spinner.big {
  width: 28px;
  height: 28px;
  border-width: 3px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading {
  display: grid;
  place-items: center;
  padding: 60px;
}
.pill {
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* Creative-type filter chips (formats / catalog / constructor / workspace) */
.chipbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.chipbar .chiplabel {
  font-size: 11px;
  color: var(--muted);
  margin-right: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chip {
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}
.chip:hover {
  border-color: var(--accent);
}
.chip.on {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

/* Manager permissions matrix (admin #managers/:id) */
.permtools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 4px 0 12px;
}
.permtools .chipbar {
  margin: 0;
  flex: 1;
  min-width: 220px;
}
.permtools-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.permtools-right input[type='search'] {
  width: 200px;
  padding: 6px 11px;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
}
.permtable td,
.permtable th {
  vertical-align: top;
}
.permtable .fmtcol {
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  font-weight: 500;
}
.permtable .fmtcol .fmticon {
  opacity: 0.85;
}
.permtable td[data-sizes] .szwrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
}
.permtable td[data-sizes] .sztools {
  display: inline-flex;
  gap: 8px;
  margin-right: 4px;
}
.permtable td[data-sizes] .szlink {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.permtable td[data-sizes] .szlink:hover {
  text-decoration: underline;
}
.permtable td[data-sizes] .szlink-x {
  color: var(--muted);
}
.permtable td[data-sizes] label {
  margin: 0 !important;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  transition:
    border-color 0.12s,
    background 0.12s;
}
.permtable td[data-sizes] label:hover {
  border-color: var(--accent);
}
.permtable td[data-sizes] label:has(input:checked) {
  border-color: transparent;
  background: var(--accent-grad);
  color: #fff;
}
.permtable td[data-sizes] label:has(input:disabled) {
  opacity: 0.45;
}

/* Two-column campaign workspace */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.fmt-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.fmt-card .ico {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.fmt-card .meta {
  flex: 1;
  min-width: 0;
}
.fmt-card .nm {
  font-weight: 700;
  font-size: 14px;
}
.fmt-card .ty {
  color: var(--muted);
  font-size: 12px;
}
.iconbtn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 15px;
}
.iconbtn:hover {
  border-color: var(--accent);
}

@media (max-width: 760px) {
  .cols {
    grid-template-columns: 1fr;
  }
  nav.tabs {
    order: 3;
    width: 100%;
  }
  .stat .v {
    font-size: 24px;
  }
  table.responsive thead {
    display: none;
  }
  table.responsive,
  table.responsive tbody,
  table.responsive tr,
  table.responsive td {
    display: block;
    width: 100%;
  }
  table.responsive tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
  }
  table.responsive td {
    border: none;
    padding: 8px 14px;
  }
}
