/* ============================================================================
 * Reseller storefront — service control panel styles.
 *
 * Loaded by reseller/views/storefront.html and served through the
 * /reseller-assets/ passthrough prefix, so it resolves both on a reseller's own
 * domain and on the /p/<slug> preview path.
 *
 * Builds on client-area.css: the tokens, buttons, cards, tables and forms all
 * come from there, and nothing here hardcodes a brand colour — every value is a
 * CSS custom property the storefront sets at runtime from the panel's branding.
 * ========================================================================== */

/* A view painted inside the shell's .wrap should not re-constrain itself. */
.wrap .wrap { max-width: none; padding: 0; }

/* ------------------------------------------------------------------ sub-tabs */

/*
 * Segmented control rather than the old underlined row: it reads as a group of
 * destinations, survives wrapping on a narrow screen, and the active item is
 * legible without relying on a 2px border.
 */
.sp-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px;
  margin: 0 0 18px;
  background: color-mix(in srgb, var(--surface) 70%, #000);
  border: var(--hairline);
  border-radius: 12px;
  scrollbar-width: none;
}
.sp-tabs::-webkit-scrollbar { display: none; }

.sp-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  padding: 8px 14px;
  font: inherit;
  font-size: .89rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.sp-tab svg { width: 15px; height: 15px; }
.sp-tab:hover { color: var(--text); background: var(--surface-2); }
.sp-tab.active {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: color-mix(in srgb, var(--primary) 34%, transparent);
}
.sp-tab.active svg { color: var(--primary); }

/* ------------------------------------------------------------- power controls */

/* The power group lives in the page header, so it is reachable from every tab
   rather than only from the console. */
.sp-power { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------- status rail */

/*
 * The right-hand column of the console view: everything about "how is my server
 * doing" in one place, so the console itself gets the full width of the main
 * column instead of being squeezed under a metric strip.
 */
.sp-rail { display: grid; gap: 16px; }

.sp-rail .card { padding: 0; }
.sp-rail .card > .card-head { margin: 0; }
.sp-rail .rows { padding: 6px 18px 14px; }

.sp-usage { padding: 4px 18px 18px; display: grid; gap: 14px; }
.sp-usage .k {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.sp-usage .k .v { margin-left: auto; color: var(--text); font-weight: 600; font-size: .85rem; }

/* Address / secret value with a copy affordance. */
.sp-copy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text);
  border: none;
  background: none;
  padding: 0;
  text-align: right;
  overflow-wrap: anywhere;
}
.sp-copy svg { width: 13px; height: 13px; opacity: .6; flex: 0 0 13px; }
.sp-copy:hover { color: var(--primary); }
.sp-copy:hover svg { opacity: 1; }

/* ------------------------------------------------------- compact metric strip */

/* Shown above the non-console tabs, where the full rail would steal width. */
.sp-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 16px;
}
.sp-metric {
  background: var(--surface);
  border: var(--hairline);
  border-radius: 12px;
  padding: 13px 15px;
}
.sp-metric .k {
  color: var(--muted);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  margin-bottom: 5px;
}
.sp-metric .v { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.sp-metric .sub { color: var(--muted); font-size: .76rem; margin-top: 3px; }

/* Thin usage bar under a metric. Width is set inline from live data. */
.sp-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  margin-top: 8px;
  overflow: hidden;
}
.sp-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .4s ease;
}
.sp-bar.warn > span { background: var(--warn); }
.sp-bar.danger > span { background: var(--danger); }

/* Live state pill, reused by the header and the rail. */
.sp-state { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--muted); }
.sp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 8px; }
.sp-dot.running { background: var(--ok); box-shadow: 0 0 0 3px rgba(53, 198, 138, .2); }
.sp-dot.starting, .sp-dot.stopping { background: var(--warn); box-shadow: 0 0 0 3px rgba(240, 178, 60, .18); }
.sp-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(244, 102, 95, .18); }

/* ------------------------------------------------------------------- console */

.sp-console {
  background: #05070c;
  border-top: var(--hairline);
  border-bottom: var(--hairline);
  padding: 14px 18px;
  height: 470px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .81rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d6e2f5;
  margin: 0;
  scrollbar-width: thin;
}
.sp-console::-webkit-scrollbar { width: 10px; }
.sp-console::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 999px; }

/* Command bar, docked under the console inside the same card. */
.sp-cmd { display: flex; gap: 10px; padding: 14px 18px; }
.sp-cmd input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
}
.sp-cmd input:disabled { opacity: .55; cursor: not-allowed; }

/* "Jump to newest" button, shown only while the customer has scrolled back. */
.sp-console-wrap { position: relative; }
.sp-jump {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 2;
}

/* --------------------------------------------------------- quick commands */

/*
 * Preset commands for the game the service runs. Saves a customer having to
 * remember exact syntax, which is the single most common support question.
 */
.sp-quick {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  padding: 18px;
}
.sp-quick button {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  background: var(--surface-2);
  border: var(--hairline);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.sp-quick button:hover { border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.sp-quick button:disabled { opacity: .5; cursor: not-allowed; }
.sp-quick .ico {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}
.sp-quick .ico svg { width: 15px; height: 15px; }
.sp-quick .cmd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
  font-weight: 600;
}
.sp-quick .desc { color: var(--muted); font-size: .76rem; }

/* -------------------------------------------------------------- file manager */

.sp-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: .87rem;
}
.sp-crumbs button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  padding: 2px 5px;
  border-radius: 6px;
}
.sp-crumbs button:hover { background: var(--surface-2); }
.sp-crumbs .sep { color: var(--muted); opacity: .6; }
.sp-crumbs .current { color: var(--text); font-weight: 600; }

.sp-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 18px;
  border-bottom: var(--hairline);
}
.sp-toolbar .grow { margin-left: auto; }

.sp-files { width: 100%; border-collapse: collapse; font-size: .88rem; }
.sp-files th, .sp-files td { text-align: left; padding: 9px 12px; border-bottom: var(--hairline); }
.sp-files th {
  color: var(--muted);
  font-size: .69rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}
.sp-files tbody tr:hover { background: rgba(255, 255, 255, .028); }
.sp-files tr:last-child td { border-bottom: none; }
.sp-files td.tight, .sp-files th.tight { width: 1%; white-space: nowrap; }
.sp-files .name {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
}
.sp-files .name:hover { color: var(--primary); }
.sp-files .icon { flex: 0 0 16px; width: 16px; height: 16px; opacity: .7; }
.sp-files .icon.dir { color: var(--primary); opacity: .95; }
.sp-files input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; accent-color: var(--primary); }
.sp-files .row-tools { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------------------------------- editor */

.sp-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 18px;
  border-bottom: var(--hairline);
}
.sp-editor-head .path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .83rem;
  color: var(--muted);
  word-break: break-all;
}
.sp-editor-head .grow { margin-left: auto; }

.sp-editor {
  width: 100%;
  min-height: 500px;
  background: #05070c;
  border: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 15px 18px;
  color: #d6e2f5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .83rem;
  line-height: 1.6;
  resize: vertical;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  display: block;
}
.sp-editor:focus { outline: none; box-shadow: none; border: none; }

/* -------------------------------------------------------------- credentials */

.sp-secret {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: var(--hairline);
  border-radius: 9px;
  padding: 8px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  word-break: break-all;
}
.sp-secret .grow { margin-left: auto; flex: 0 0 auto; }

/* A database entry: its own bordered block inside the databases card. */
.sp-db {
  background: var(--surface-2);
  border: var(--hairline);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.sp-db + .sp-db { margin-top: 12px; }
.sp-db-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sp-db-head strong { font-size: .98rem; }
.sp-db-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* --------------------------------------------------------------- misc pieces */

.sp-danger { border-color: rgba(244, 102, 95, .32); background: rgba(244, 102, 95, .05); }
.sp-empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.sp-hint { color: var(--muted); font-size: .86rem; margin: 0 0 16px; }
.sp-section { padding: 18px; }

.sp-var { padding: 14px 0; border-bottom: var(--hairline); }
.sp-var:first-child { padding-top: 0; }
.sp-var:last-child { border-bottom: none; padding-bottom: 0; }
.sp-var label { margin-bottom: 4px; color: var(--text); font-weight: 600; font-size: .89rem; }
.sp-var .desc { color: var(--muted); font-size: .81rem; margin: 0 0 8px; }
.sp-var .save-row { display: flex; gap: 8px; align-items: center; }
.sp-var .save-row input { flex: 1; }

/* Drag-and-drop upload target. */
.sp-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 22px;
  margin: 16px 18px 0;
  text-align: center;
  color: var(--muted);
  font-size: .87rem;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.sp-drop.over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  color: var(--text);
}

/* Progress line used by uploads. */
.sp-progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  margin: 12px 18px 0;
}
.sp-progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .2s ease;
}

/* --------------------------------------------------------- installing screen */

.sp-install-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  animation: sp-install-spin 1s linear infinite;
}
@keyframes sp-install-spin { to { transform: rotate(360deg); } }

.sp-install-bar {
  height: 6px;
  width: 100%;
  max-width: 320px;
  margin: 26px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}
.sp-install-bar > span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  animation: sp-install-slide 1.6s ease-in-out infinite;
}
@keyframes sp-install-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 640px) {
  .sp-console { height: 330px; font-size: .77rem; }
  .sp-files .hide-sm { display: none; }
  .sp-quick { grid-template-columns: 1fr; }
  .sp-power { width: 100%; }
  .sp-power .btn { flex: 1; }
}

/* ---------------------------------------------------------- icon containers */

/* Wrappers that size their icon rather than letting it inherit the text size. */
.sp-files .icon svg { width: 100%; height: 100%; }

.sp-db-head .ico {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}
.sp-db-head .ico svg { width: 15px; height: 15px; }
