/* Cabbit dashboard — Discord-flavoured dark theme, no framework. */

:root {
  --bg: #1e1f22;
  --bg-raised: #2b2d31;
  --bg-input: #1e1f22;
  --bg-hover: #35373c;
  --border: #3f4147;
  --text: #f2f3f5;
  --text-muted: #b5bac1;
  --text-faint: #80848e;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #23a55a;
  --red: #da373c;
  --yellow: #f0b232;
  --grey-btn: #4e5058;
  --radius: 10px;
  --shadow: 0 8px 24px rgb(0 0 0 / 35%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "gg sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}
.small {
  font-size: 13px;
}
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* --- Login ---------------------------------------------------------------- */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #2f3136 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: var(--bg-raised);
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  font-size: 44px;
  line-height: 1;
}

.login-card h1 {
  margin: 12px 0 4px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 20px;
}

.login-card .field {
  text-align: left;
}

/* --- Layout --------------------------------------------------------------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-weight: 700;
  font-size: 17px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-input);
  font-size: 13px;
  font-weight: 600;
}

.pill .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
}

.pill-online .dot {
  background: var(--green);
}
.pill-offline .dot {
  background: var(--red);
}
.pill-idle .dot {
  background: var(--yellow);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
  gap: 20px;
  align-items: start;
  padding: 20px 24px 120px;
  flex: 1;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.column-preview {
  position: sticky;
  top: 84px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .column-preview {
    position: static;
  }
}

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 620px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Fields --------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field > span em,
.hint {
  font-style: normal;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-faint);
  font-size: 12px;
}

.counter.over {
  color: var(--red);
  font-weight: 700;
}

input[type="text"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blurple);
}

input.invalid,
select.invalid {
  border-color: var(--red);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* Password field with a reveal toggle sitting inside the input. */
.password-row {
  position: relative;
  display: block;
}

.password-row input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 34px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.password-toggle:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: 1px;
  opacity: 1;
}

.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  cursor: pointer;
}

.color-row input[type="text"] {
  flex: 1;
  text-transform: uppercase;
}

.checkbox-field {
  justify-content: flex-start;
}

/* Switch */
.switch {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  flex: none;
  position: relative;
  width: 40px;
  height: 24px;
  margin-top: 1px;
  border-radius: 999px;
  background: var(--grey-btn);
  transition: background 0.15s ease;
}

.switch .slider::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + .slider {
  background: var(--green);
}

.switch input:checked + .slider::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .slider {
  outline: 2px solid var(--blurple);
  outline-offset: 2px;
}

.switch-label {
  font-size: 14px;
  color: var(--text-muted);
}

.switch-label strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.switch-label em {
  font-style: normal;
  font-size: 12px;
  color: var(--text-faint);
}

.advanced {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.advanced > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
}

/* Child combinators throughout: a panel card is itself a <details>, so a
   descendant selector would put a second triangle on the disclosure nested
   inside it. */
.advanced > summary::before {
  content: "▸ ";
}

.advanced[open] > summary::before {
  content: "▾ ";
}

summary::-webkit-details-marker {
  display: none;
}

.advanced > .grid-2 {
  margin-top: 14px;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--grey-btn);
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #6d6f78;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blurple);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blurple-hover);
}

.btn-secondary {
  background: var(--grey-btn);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--red);
}
.btn-danger-ghost:hover:not(:disabled) {
  background: rgb(218 55 60 / 12%);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.btn-icon {
  padding: 6px 9px;
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--red);
}

.chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-input);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.chip.over {
  background: var(--red);
  color: #fff;
}

/* --- Warnings ------------------------------------------------------------- */

.warnings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 24px;
}

.warnings:not(:empty) {
  padding-top: 16px;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  border-left: 4px solid;
}

.banner-error {
  background: rgb(218 55 60 / 12%);
  border-color: var(--red);
}

.banner-warn {
  background: rgb(240 178 50 / 12%);
  border-color: var(--yellow);
}

.banner-info {
  background: rgb(88 101 242 / 12%);
  border-color: var(--blurple);
}

.error-text {
  color: var(--red);
  font-size: 13px;
  margin: 0 0 8px;
}

/* --- Role rows ------------------------------------------------------------ */

.role-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.role-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 2fr) minmax(0, 2fr) 74px 116px 36px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 8px;
}

.role-row.dragging {
  opacity: 0.4;
}

.role-row.drop-target {
  border-color: var(--blurple);
}

.role-row.row-error {
  border-color: var(--red);
}

.role-row .drag-handle {
  cursor: grab;
  color: var(--text-faint);
  text-align: center;
  font-size: 16px;
  user-select: none;
}

.role-row input,
.role-row select {
  padding: 8px 10px;
  font-size: 14px;
  background: var(--bg-raised);
}

.role-row select {
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  padding-right: 26px;
}

.role-row-warning {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--red);
  padding-left: 32px;
}

.role-rows-header {
  display: grid;
  grid-template-columns: 24px minmax(0, 2fr) minmax(0, 2fr) 74px 116px 36px;
  gap: 8px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

@media (max-width: 780px) {
  .role-row,
  .role-rows-header {
    grid-template-columns: 24px minmax(0, 1fr) 36px;
  }
  .role-rows-header {
    display: none;
  }
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.panel-state {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.panel-state a {
  color: #00a8fc;
  text-decoration: none;
}

.panel-state a:hover {
  text-decoration: underline;
}

/* --- Discord preview ------------------------------------------------------ */

.preview-card {
  padding-bottom: 22px;
}

.discord-preview {
  background: #313338;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
}

.dm-row {
  display: flex;
  gap: 14px;
}

.dm-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blurple);
  display: grid;
  place-items: center;
  font-size: 20px;
  overflow: hidden;
}

.dm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-body {
  min-width: 0;
  flex: 1;
}

.dm-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.dm-name {
  font-weight: 600;
  color: #f2f3f5;
}

.dm-tag {
  background: var(--blurple);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

.dm-time {
  font-size: 12px;
  color: var(--text-faint);
}

.embed {
  display: grid;
  grid-template-columns: 4px 1fr;
  max-width: 432px;
  background: #2b2d31;
  border-radius: 4px;
  overflow: hidden;
}

.embed-bar {
  background: var(--blurple);
}

.embed-content {
  display: flex;
  gap: 12px;
  padding: 12px 16px 0 12px;
  grid-column: 2;
}

.embed-text {
  min-width: 0;
  flex: 1;
}

.embed-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.embed-author-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.embed-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #f2f3f5;
  word-wrap: break-word;
}

.embed-description {
  font-size: 14px;
  color: #dbdee1;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.embed-description code,
.embed-title code {
  background: #1e1f22;
  border-radius: 3px;
  padding: 1px 3px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.embed-thumbnail {
  flex: none;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}

.embed-image {
  grid-column: 2;
  max-width: 100%;
  margin: 12px 16px 0 12px;
  border-radius: 4px;
}

.embed-footer {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px 12px;
  font-size: 12px;
  color: #949ba4;
}

.embed-footer-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

/* Embeds with no body padding still need bottom breathing room. */
.embed-content:last-child {
  padding-bottom: 12px;
}

.preview-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-width: 432px;
}

.preview-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.d-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--blurple);
  min-height: 32px;
  cursor: default;
}

.d-btn-primary {
  background: var(--blurple);
}
.d-btn-secondary {
  background: #4e5058;
}
.d-btn-success {
  background: #248046;
}
.d-btn-danger {
  background: #da373c;
}

.preview-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
}

/* --- Action bar ----------------------------------------------------------- */

.actionbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgb(0 0 0 / 25%);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actionbar .unsaved {
  color: var(--yellow);
  font-weight: 600;
}

/* --- Toasts --------------------------------------------------------------- */

.toasts {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 48px));
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--bg-raised);
  border-left: 4px solid var(--blurple);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 0.16s ease-out;
}

.toast-success {
  border-color: var(--green);
}
.toast-error {
  border-color: var(--red);
}

.toast ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Server picker -------------------------------------------------------- */

.login-card-wide {
  max-width: 520px;
}

.guild-picker-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.guild-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.guild-card:hover {
  background: var(--bg-hover);
  border-color: var(--blurple);
}

.guild-card:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: 2px;
}

.guild-card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--grey-btn);
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
}

.guild-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guild-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.guild-card-body strong {
  font-size: 15px;
}

.guild-card-body em {
  font-style: normal;
  font-size: 12px;
  color: var(--text-faint);
}

.guild-card-body em.warn {
  color: var(--yellow);
}

/* --- Server switcher ------------------------------------------------------ */

.guild-switcher select {
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 200px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Panel cards ---------------------------------------------------------- */

#panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  padding: 0;
}

/* The summary IS the collapsed card, so it carries the card's padding. */
.panel-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.panel-summary:hover {
  background: var(--bg-hover);
  border-radius: var(--radius);
}

.panel-card[open] > .panel-summary {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid var(--border);
}

.disclosure > summary::before {
  content: "▸";
  color: var(--text-faint);
  font-size: 12px;
}

.disclosure[open] > summary::before {
  content: "▾";
}

.panel-summary:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: -2px;
}

.panel-name-text {
  font-size: 14px;
  font-weight: 600;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.panel-badge-live {
  color: var(--green);
  background: rgb(35 165 90 / 15%);
}

.panel-badge-warn {
  color: var(--yellow);
  background: rgb(240 178 50 / 15%);
}

.panel-dirty {
  color: var(--yellow);
  font-size: 14px;
  line-height: 1;
}

.panel-body {
  padding: 16px 20px 18px;
}

.card-head-tight {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.switch-block {
  margin-top: 16px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* --- Modal ---------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(0 0 0 / 60%);
}

.modal-card {
  width: 100%;
  max-width: 460px;
  padding: 22px 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
