@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  /* ACO dark green theme — matches helpmecheckout landing page */
  --bg: #0d1b16;
  --bg-surface: #111e19;
  --panel: #131f1a;
  --panel-elevated: #1a2b24;
  --bg-hover: #1e3029;
  --border: #1e3029;
  --border-strong: #2a4038;

  --text: #f6fff8;
  --text-muted: #a4c3b2;
  --text-hint: #6b9080;
  --text-faint: #4a6b5d;

  --primary: #34d399;          /* bright emerald accent */
  --primary-hover: #4ade80;
  --primary-soft: rgba(52, 211, 153, 0.12);
  --primary-dim: #6b9080;       /* sage, for less-prominent things */

  --success: #34d399;
  --danger: #ef4444;
  --discord: #5865F2;
  --discord-hover: #4752c4;

  --radius: 8px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

.hidden {
  display: none !important;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 0%, #1a2b24 0%, var(--bg) 60%);
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
}

.login-card p {
  margin: 0 0 28px;
  color: var(--text-muted);
}

.discord-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--discord);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s;
}

.discord-btn:hover {
  background: var(--discord-hover);
}

.login-error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 13px;
}

/* ---------- App layout ---------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

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

.user-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.user-info img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.usage {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 12px 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 200px;
  position: relative;
}

.usage-text {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
  padding-right: 22px; /* room for refresh button */
}

.usage-divider {
  color: var(--text-faint);
}

.usage-percent {
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.usage-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.4s ease, background 0.2s;
}

.usage-bar-fill.is-warning {
  background: #fbbf24;
}

.usage-bar-fill.is-danger {
  background: #ef4444;
}

.usage.is-error .usage-text {
  color: var(--danger);
}

.usage-refresh {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: none;
  padding: 4px;
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.usage-refresh:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.usage-refresh.is-loading svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.logout-btn:hover {
  background: var(--bg);
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
}

.panel {
  background: var(--panel);
  padding: 24px;
  overflow-y: auto;
}

.section {
  margin-bottom: 28px;
}

.section h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

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

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

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field .hint {
  font-size: 12px;
  color: var(--text-hint);
  font-weight: 400;
}

.hint {
  font-size: 12px;
  color: var(--text-hint);
  margin: 8px 0 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--panel-elevated);
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  min-height: 220px;
  background: var(--bg-surface);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input[readonly] {
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: default;
}

input:disabled,
select:disabled {
  background: var(--bg);
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 0.5;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none' stroke='%23a4c3b2' stroke-width='1.5'><polyline points='1 1 5 5 9 1'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 28px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.grid-span-2 {
  grid-column: 1 / -1;
}

.auth-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.select-with-fav {
  display: flex;
  gap: 6px;
  align-items: stretch;
  min-width: 0;
}

.select-with-fav select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ---------- Combobox (ASN dropdown with built-in search) ---------- */

.combobox {
  position: relative;
  flex: 1;
  min-width: 0;
}

.combobox-input {
  width: 100%;
  padding-right: 30px; /* room for clear button */
}

.combobox-input.has-value {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none' stroke='%236b7280' stroke-width='1.5'><polyline points='1 1 5 5 9 1'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.combobox-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  border-radius: 3px;
}

.combobox-clear:hover {
  color: var(--text);
  background: var(--bg);
}

.combobox.has-value .combobox-clear {
  display: inline-flex;
}

.combobox-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}

.combobox-group-label {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-hint);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.combobox-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-option:hover,
.combobox-option.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.combobox-option.is-selected {
  font-weight: 600;
  color: var(--primary);
}

.combobox-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--text-hint);
  text-align: center;
}

.fav-btn {
  background: var(--panel-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.fav-btn:hover:not(:disabled) {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-color: #fbbf24;
}

.fav-btn.is-favorited {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-color: #fbbf24;
}

.fav-btn.is-favorited svg {
  fill: currentColor;
}

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

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 36px;
}

.password-wrap .icon-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
}

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

/* ---------- Session settings ---------- */

.session-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.radio input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.sesstime-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sesstime-wrap input {
  width: 80px;
}

.sesstime-wrap .unit {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Right panel: outputs ---------- */

.copyrow {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copyrow input {
  font-family: var(--mono);
  font-size: 12px;
}

.string-parts {
  display: grid;
  grid-template-columns: 2fr auto 70px auto 1.5fr auto 1.5fr auto;
  gap: 6px;
  align-items: center;
}

.string-parts input {
  font-family: var(--mono);
  font-size: 12px;
}

.string-parts .sep {
  color: var(--text-hint);
  font-weight: 600;
}

.output-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  margin-bottom: 12px;
  gap: 16px 24px;
}

.output-format,
.output-count {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.output-format .label,
.output-count .label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.output-format select {
  min-width: 240px;
}

.output-count input {
  width: 120px;
}

.output-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary-dim);
}

.btn-primary {
  background: var(--primary);
  color: #0d1b16;
  border-color: var(--primary);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #0d1b16;
}

.toast {
  margin: 10px 0 0;
  padding: 9px 14px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--primary);
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: var(--radius);
  font-size: 13px;
  transition: opacity 0.2s;
}

.toast.error {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary);
}

/* ---------- Quick-pick pill buttons ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.pill:hover {
  border-color: var(--primary-dim);
  color: var(--text);
}

.pill.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- Segmented toggle (Rotating / Sticky) ---------- */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.segmented-option {
  padding: 9px 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented-option:hover:not(.is-active) {
  color: var(--text);
}

.segmented-option.is-active {
  background: var(--primary);
  color: #0d1b16;
}

.section-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-hint);
  margin-bottom: 8px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }

  .auth-display,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .string-parts {
    grid-template-columns: 1fr;
  }

  .string-parts .sep {
    display: none;
  }
}
