/* ──────────────────────────────────────────────────────────────────────
   TicketDesk Dashboard — Phase 2c CSS (combined, latest)
   Replaces the previous dashboard-2c.css.

   Updates in 2c-perms:
   - .perm-admin-box highlighted container for is_admin toggle
   - .perm-toggle-implied + .perm-list-implied (when admin is on)
   - .perm-group-name / .perm-group-desc styling
   - .perm-chip-more for "+N more" overflow
   ──────────────────────────────────────────────────────────────────── */

/* ═════════════════════════ 2c-1: Categories ════════════════════════ */

.page-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.cat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .12s;
}
.cat-card:hover { border-color: var(--border-h); }
.cat-card-head { display: flex; align-items: flex-start; gap: 10px; }
.cat-card-emoji {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border-radius: 8px;
}
.cat-card-title { flex: 1; min-width: 0; }
.cat-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--t);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.cat-card-actions .btn { padding: 5px 8px; }
.cat-card-actions svg { display: block; }
.cat-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.cat-card-row { display: flex; justify-content: space-between; gap: 8px; }
.cat-card-row-label { color: var(--t-d); }
.cat-card-row-value { color: var(--t-m); }

/* ── Modal infrastructure (shared) ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: modalIn .15s ease-out;
}
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-h);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: modalSlide .2s ease-out;
}
.modal-wide { max-width: 760px; }
@keyframes modalSlide {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--t-m);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  transition: all .12s;
}
.modal-close:hover { background: var(--bg-3); color: var(--t); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

/* ── Form layout ──────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 12px;
  margin-bottom: 8px;
}
.form-grid .form-row { margin-bottom: 0; }
.form-row-name { grid-column: 1 / 2; }
.form-row-emoji { grid-column: 2 / 3; }
.form-grid .form-row:nth-child(3) { grid-column: 1 / 2; }
.form-grid .form-row:nth-child(4) { grid-column: 2 / 3; }
.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--t-m);
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-label .required { color: var(--acc); font-weight: 600; }
.form-hint { font-size: 11px; color: var(--t-d); margin-top: 2px; }
.input, input.input, select.input, textarea.input {
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--t);
  font-family: inherit;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-dim); }
textarea.input { resize: vertical; min-height: 60px; font-family: inherit; }
.form-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.form-section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--t);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.form-section-optional {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--t-d);
  font-style: italic;
  text-transform: lowercase;
}
.form-section-desc { font-size: 12px; color: var(--t-d); margin: 0 0 12px 0; line-height: 1.5; }
.form-section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.form-section-head .form-section-title, .form-section-head .form-section-desc { margin-bottom: 0; }

/* Color picker */
.color-picker { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--border-h);
  cursor: pointer;
  transition: all .12s;
  padding: 0;
}
.color-swatch:hover { transform: scale(1.08); border-color: var(--t-d); }
.color-swatch.active {
  border-color: var(--t);
  box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--acc);
}
.color-input { width: 100px; font-family: var(--mono); font-size: 12px; }

/* Role multi-select (categories page) */
.role-multi { display: flex; flex-direction: column; gap: 8px; }
.role-chips { display: flex; flex-wrap: wrap; gap: 5px; min-height: 28px; padding: 4px 0; }
.role-empty { font-size: 12px; color: var(--t-d); font-style: italic; padding: 4px 0; }
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border-h);
  border-radius: 999px;
  padding: 3px 4px 3px 8px;
  font-size: 12px;
  color: var(--t);
}
.role-chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--role-color, #888); flex-shrink: 0; }
.role-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.role-chip-remove {
  background: transparent; border: none; color: var(--t-m);
  cursor: pointer; padding: 2px; border-radius: 50%;
  display: flex; transition: all .12s;
}
.role-chip-remove:hover { background: var(--bg-1); color: var(--t); }
.role-add { font-size: 12px; }

/* Form fields builder (modal questions) */
.form-fields-empty { font-size: 12px; color: var(--t-d); font-style: italic; padding: 8px 0; }
.form-fields-list { display: flex; flex-direction: column; gap: 8px; }
.form-field-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.form-field-num {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--t-d);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3);
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}
.form-field-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: center; }
.form-field-label { grid-column: 1 / 3; }
.form-field-required {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--t-m);
  cursor: pointer; user-select: none; padding: 4px 0;
}
.form-field-required input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--acc); cursor: pointer;
}
.form-field-max { width: 100%; }
.form-field-remove { padding: 5px 8px !important; flex-shrink: 0; }
.form-field-remove svg { display: block; }

/* ═════════════════════════ 2c-2: Panels ════════════════════════════ */

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}
.panel-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .12s;
}
.panel-card:hover { border-color: var(--border-h); }
.panel-card.status-pending { border-color: rgba(246, 163, 46, 0.4); }
.panel-card.status-deployed { border-color: rgba(34, 211, 160, 0.3); }
.panel-card-head { display: flex; align-items: flex-start; gap: 10px; }
.panel-card-info { flex: 1; min-width: 0; }
.panel-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--t);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.panel-card-desc { font-size: 12px; color: var(--t-m); line-height: 1.45; }
.panel-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.panel-card-actions .btn { padding: 5px 8px; }
.panel-card-actions svg { display: block; }
.panel-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--t-m);
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.panel-card-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.panel-card-meta-item svg { color: var(--t-d); }
.panel-card-footer { display: flex; justify-content: flex-end; gap: 6px; }
.panel-card-footer .btn svg { display: inline-block; vertical-align: middle; margin-right: 3px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid;
  letter-spacing: .02em;
}
.status-pill .status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill-deployed { color: #22d3a0; border-color: rgba(34, 211, 160, 0.4); background: rgba(34, 211, 160, 0.08); }
.status-pill-deployed .status-dot { background: #22d3a0; }
.status-pill-not_deployed { color: var(--t-d); border-color: var(--border-h); background: var(--bg-3); }
.status-pill-not_deployed .status-dot { background: var(--t-d); }
.status-pill-pending { color: #f6a32e; border-color: rgba(246, 163, 46, 0.4); background: rgba(246, 163, 46, 0.08); }
.status-pill-pending .status-dot { background: #f6a32e; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.btn.btn-amber { background: #f6a32e; color: #1a1100; border-color: #f6a32e; }
.btn.btn-amber:hover { background: #ffb84a; border-color: #ffb84a; }

.panel-cat-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.panel-cat-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.panel-cat-reorder { display: flex; flex-direction: column; gap: 2px; }
.reorder-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--t-m);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 16px;
  transition: all .12s;
}
.reorder-btn:hover:not(:disabled) { background: var(--bg-1); color: var(--t); }
.reorder-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.panel-cat-info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.panel-cat-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-cat-overrides { display: grid; grid-template-columns: 80px 1fr; gap: 6px; }
.panel-cat-emoji { text-align: center; font-size: 13px; }
.panel-cat-remove { padding: 5px 8px !important; flex-shrink: 0; }
.panel-cat-remove svg { display: block; }
.panel-cat-add { margin-top: 4px; }

/* ═════════════════════════ 2c-3 / 2c-perms: Team ═══════════════════ */

/* Dismissable callout (Team intro + reusable) */
.dismissable-callout {
  display: flex;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--acc);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--t-m);
  margin-bottom: 18px;
  line-height: 1.5;
}
.dismissable-callout-icon { color: var(--acc); flex-shrink: 0; padding-top: 1px; }
.dismissable-callout-body { flex: 1; min-width: 0; }
.dismissable-callout-body strong { color: var(--t); font-weight: 600; }
.dismissable-callout-body code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 3px;
}
.dismissable-callout-close {
  background: transparent;
  border: none;
  color: var(--t-d);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  flex-shrink: 0;
  align-self: flex-start;
  transition: all .12s;
}
.dismissable-callout-close:hover { background: var(--bg-3); color: var(--t); }

/* Team list (full-width rows) */
.team-rows { display: flex; flex-direction: column; gap: 6px; }
.team-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .12s;
}
.team-row:hover {
  background: var(--bg-3);
  border-color: var(--border-h);
}
.role-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.team-row-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-row-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}
.team-row-gear {
  padding: 5px 8px !important;
  flex-shrink: 0;
  color: var(--t-d) !important;
}
.team-row-gear svg { display: block; }
.team-row:hover .team-row-gear { color: var(--t) !important; }

/* Permission chips (Team list summary) */
.perm-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border-h);
  color: var(--t-m);
  white-space: nowrap;
  font-weight: 500;
}
.perm-chip-is_admin {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--acc-l, #b794f6);
  font-weight: 600;
}
.perm-chip-more {
  font-style: italic;
  color: var(--t-d);
  background: transparent;
  border-color: transparent;
}
.perm-chip-empty {
  font-size: 11px;
  color: var(--t-d);
  font-style: italic;
}

/* Modal: Admin highlighted box (master switch at top) */
.perm-admin-box {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 8px;
  padding: 4px 6px;
  margin-bottom: 18px;
}
.perm-admin-box .perm-toggle {
  padding: 8px 8px;
}
.perm-admin-box .perm-toggle:hover {
  background: rgba(139, 92, 246, 0.08);
}
.perm-admin-box .perm-toggle-label {
  font-weight: 600;
}

/* Modal: granular permission groups */
.perm-group {
  margin-top: 14px;
}
.perm-group:first-child {
  margin-top: 0;
}
.perm-group-head {
  margin-bottom: 6px;
  padding-left: 4px;
}
.perm-group-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--t-m);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.perm-group-desc {
  font-size: 11px;
  color: var(--t-d);
  margin-top: 1px;
}

/* Permission list inside modals (with toggle switches) */
.perm-list-modal {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* When admin is enabled, granular sections look "implied" */
.perm-list-implied .perm-toggle {
  cursor: not-allowed;
}
.perm-toggle {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.perm-toggle:hover { background: var(--bg-3); }
.perm-toggle-implied {
  opacity: 0.55;
}
.perm-toggle-implied:hover {
  background: transparent;
}
.perm-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-track {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  background: var(--bg-3);
  border: 1px solid var(--border-h);
  border-radius: 999px;
  transition: all .15s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: var(--t-m);
  border-radius: 50%;
  transition: all .15s ease-out;
}
.perm-toggle input:checked + .toggle-track {
  background: var(--acc);
  border-color: var(--acc);
}
.perm-toggle input:checked + .toggle-track .toggle-thumb {
  left: 15px;
  background: white;
}
.perm-toggle input:disabled + .toggle-track {
  opacity: 0.8;
}
.perm-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.perm-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--t);
}
.perm-toggle-desc {
  font-size: 11.5px;
  color: var(--t-d);
  line-height: 1.4;
}

/* Modal danger zone (e.g. remove role) */
.modal-danger-zone {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.btn-danger {
  background: transparent;
  color: #ff7c7c;
  border: 1px solid rgba(242, 92, 92, 0.3);
}
.btn-danger:hover {
  background: rgba(242, 92, 92, 0.1);
  border-color: #f25c5c;
  color: #ff9494;
}
.btn-danger svg {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── Mobile tweaks ────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-row-name, .form-row-emoji,
  .form-grid .form-row:nth-child(3),
  .form-grid .form-row:nth-child(4) { grid-column: 1 / 2; }
  .form-field-inputs { grid-template-columns: 1fr; }
  .form-field-label { grid-column: 1 / 2; }
  .modal { max-width: 100%; max-height: 95vh; }
  .modal-wide { max-width: 100%; }
  .panel-grid { grid-template-columns: 1fr; }
  .panel-cat-overrides { grid-template-columns: 1fr; }
  .team-row { grid-template-columns: 12px 1fr auto; }
  .team-row-perms {
    grid-column: 1 / 4;
    justify-content: flex-start;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
}
