/* kiosk-fleet-manager — IT-app visual language (vanilla CSS). */

:root {
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-bg: #eff6ff;
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;

  --color-bg: #f9fafb;
  --color-panel: #ffffff;
  --color-panel-alt: #f3f4f6;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-text: #111827;
  --color-text-dim: #6b7280;
  --color-text-faint: #9ca3af;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --topbar-h: 64px;
  --sidebar-w: 256px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

a { color: var(--color-primary-hover); text-decoration: none; }
a:hover { color: var(--color-primary); }

/* ----- buttons ----- */
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover:not(:disabled) { background: var(--color-panel-alt); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button.primary:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button.secondary {
  background: #4b5563;
  border-color: #4b5563;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button.secondary:hover:not(:disabled) {
  background: #374151;
  border-color: #374151;
}

button.danger {
  background: var(--color-panel);
  border-color: var(--color-border);
  color: var(--color-danger);
}
button.danger:hover:not(:disabled) {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-dim);
  padding: 6px 8px;
}
button.ghost:hover:not(:disabled) {
  background: var(--color-panel-alt);
  color: var(--color-text);
}

button.xs {
  padding: 4px 10px;
  font-size: 12px;
}

button svg { width: 14px; height: 14px; }
button.xs svg { width: 12px; height: 12px; }

/* ----- inputs ----- */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-panel);
  color: var(--color-text);
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ----- login view ----- */
.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--color-bg);
}
.login-card {
  width: min(380px, 92vw);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card .login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}
.login-card .login-logo img { height: 40px; width: auto; }
.login-card h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-dim);
  font-weight: 500;
}
/* password show/hide toggle */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrapper input { padding-right: 38px; }
.password-toggle {
  position: absolute;
  right: 4px;
  background: transparent;
  border: none;
  color: var(--color-text-dim);
  padding: 4px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.password-toggle:hover { color: var(--color-text); }
.password-toggle svg { width: 18px; height: 18px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-row > label { flex: 1 1 180px; }

.login-card button[type="submit"] {
  background: var(--color-primary-hover);
  color: #fff;
  border-color: var(--color-primary-hover);
  padding: 10px;
  justify-content: center;
  font-weight: 600;
}
.login-card button[type="submit"]:hover { background: #1d4ed8; border-color: #1d4ed8; }
.error { color: var(--color-danger); font-size: 13px; }

/* ----- topbar ----- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--color-panel);
  box-shadow: var(--shadow-md);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-hamburger {
  background: transparent;
  border: none;
  color: var(--color-text-dim);
  padding: 8px;
  border-radius: var(--radius-sm);
}
.topbar-hamburger:hover { background: var(--color-panel-alt); color: var(--color-text); }
.topbar-hamburger svg { width: 24px; height: 24px; }
.topbar-logo { height: 32px; width: auto; display: block; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-username {
  font-size: 13px;
  color: var(--color-text-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-right button.logout {
  background: #4b5563;
  border-color: #4b5563;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.topbar-right button.logout:hover { background: #374151; border-color: #374151; }

/* ----- sidebar ----- */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--topbar-h);
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.sidebar.is-collapsed { transform: translateX(-100%); }

.sidebar-nav {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: var(--color-panel-alt); color: var(--color-text); }
.sidebar-nav a.is-active {
  background: var(--color-primary-bg);
  color: var(--color-primary-hover);
  font-weight: 600;
}
.sidebar-nav a svg { width: 20px; height: 20px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 12px;
  color: var(--color-text-faint);
  line-height: 1.5;
}
.sidebar-footer .footer-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.sidebar-footer .footer-logo img { height: 24px; width: auto; }
.sidebar-footer .footer-env { margin-bottom: 2px; }

/* ----- main view ----- */
.app-shell { min-height: 100dvh; }
.view {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 24px) 32px 32px;
  min-height: 100dvh;
  transition: margin-left 0.25s ease;
  max-width: 1920px;
}
.app-shell.sidebar-collapsed .view { margin-left: 0; }

@media (max-width: 768px) {
  .view { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 16px 16px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  .app-shell.sidebar-collapsed .sidebar { transform: translateX(-100%); }
}

/* ----- page header ----- */
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
}
.page-subtitle { color: var(--color-text-dim); font-size: 14px; margin-top: 4px; }
.page-back {
  display: inline-block;
  color: var(--color-primary-hover);
  font-size: 13px;
  margin-bottom: 8px;
}
.page-back:hover { color: var(--color-primary); text-decoration: underline; }

/* ----- card ----- */
.card {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 14px;
}
.card-hint { color: var(--color-text-dim); font-size: 13px; margin-bottom: 14px; }

.row { display: flex; align-items: center; gap: 12px; }
.row + .row { margin-top: 10px; }
.row .grow { flex: 1; }
.spacer { flex: 1; }
.mono { font-family: 'SFMono-Regular', Menlo, Consolas, monospace; }
.dim  { color: var(--color-text-dim); }

/* ----- pill / status badge ----- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-panel-alt);
  color: var(--color-text-dim);
  border: 1px solid var(--color-border);
}
.pill::before {
  content: '';
  display: block;
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.pill.ok    { color: var(--color-success); background: var(--color-success-bg); border-color: #a7f3d0; }
.pill.warn  { color: var(--color-warning); background: var(--color-warning-bg); border-color: #fcd34d; }
.pill.err   { color: var(--color-danger);  background: var(--color-danger-bg); border-color: #fecaca; }

/* ----- machines list: grouped by client → location → row ----- */
.client-group {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.client-group > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--color-panel);
}
.client-group > summary::-webkit-details-marker { display: none; }
.client-group > summary:hover { background: var(--color-panel-alt); }
.client-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
}

.client-caret {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--color-text-dim);
  border-bottom: 2px solid var(--color-text-dim);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-right: 2px;
}
details[open] > summary > .client-caret { transform: rotate(45deg); }

.location-group {
  border-top: 1px solid var(--color-border);
  background: var(--color-panel-alt);
}
.location-group > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 38px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 14px;
  color: var(--color-text);
}
.location-group > summary::-webkit-details-marker { display: none; }
.location-group > summary:hover { background: #eef0f3; }
.location-pin {
  width: 16px;
  height: 16px;
  color: var(--color-text-dim);
  flex-shrink: 0;
}
.location-name {
  font-weight: 600;
}

.pill-location {
  background: #ede9fe;
  border-color: #ddd6fe;
  color: #6d28d9;
}
.pill.neutral {
  background: var(--color-primary-bg);
  border-color: #bfdbfe;
  color: var(--color-primary-hover);
}
.pill.neutral::before { display: none; }
.pill-location::before { display: none; }

.machine-rows {
  background: var(--color-panel);
  padding: 4px 0;
}
.machine-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px 12px 58px;
  color: inherit;
  border-top: 1px solid var(--color-border);
  transition: background 0.12s;
}
.machine-row:first-child { border-top: none; }
.machine-row:hover {
  background: var(--color-panel-alt);
  color: inherit;
}
.machine-row-name .primary {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}
.machine-row-name .secondary {
  font-size: 12px;
  margin-top: 2px;
}
.machine-row-version {
  font-size: 12px;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
}
.machine-row-version strong {
  color: var(--color-text);
  font-weight: 600;
}
.pill.type-kiosk {
  background: #ede9fe;
  border-color: #ddd6fe;
  color: #6d28d9;
}
.pill.type-kiosk::before { display: none; }

@media (max-width: 640px) {
  .machine-row {
    grid-template-columns: 1fr auto;
    grid-auto-flow: row;
    padding-left: 38px;
  }
  .machine-row-version { grid-column: 1 / -1; }
}

/* ----- machine detail: header ----- */
.md-header {
  margin-bottom: 24px;
}
.md-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.md-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  word-break: break-word;
}
.md-subtitle {
  color: var(--color-text-dim);
  margin-top: 4px;
  font-size: 14px;
}

/* ----- section heading ----- */
.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.section-heading h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
}
.section-heading .spacer { flex: 1; }

/* ----- info rows ----- */
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  padding: 6px 0;
}
.info-row + .info-row { border-top: 1px dashed var(--color-border); }
.info-row .info-label { color: var(--color-text-dim); flex-shrink: 0; }
.info-row .info-value {
  color: var(--color-text);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
  min-width: 0;
}
.info-row input {
  max-width: 220px;
  text-align: right;
  padding: 4px 8px;
  font-size: 13px;
}

/* ----- kiosk card (inside Programs) ----- */
.kiosk-card {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  max-width: 520px;
}
.kiosk-card.online { border-color: #a7f3d0; background: #f0fdf4; }
.kiosk-card.offline { border-color: #fecaca; background: #fef7f7; }
.kiosk-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.kiosk-card-head h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin-right: 4px;
}
.kiosk-card-head .spacer { flex: 1; }
.kiosk-card-body { display: flex; flex-direction: column; gap: 4px; }
.kiosk-card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ----- logs pane ----- */
.logs-pane {
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 14px;
  border-radius: var(--radius-sm);
  height: 60vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----- sse pane (shared by deploy modal) ----- */
.sse-pane {
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 14px;
  border-radius: var(--radius-sm);
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.sse-pane:empty::before {
  content: '(no output yet)';
  color: #64748b;
  font-style: italic;
}

/* ----- vnc ----- */
.vnc-wrapper {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.vnc-container {
  width: 100%;
  height: 65vh;
  background: #000;
  cursor: default;
}
.vnc-wrapper:fullscreen { background: #000; }
.vnc-wrapper:fullscreen .vnc-container { height: 100vh; }

/* vnc popup view */
.vnc-popup {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: #0f172a;
}
.vnc-popup-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
}
.vnc-popup-title { font-size: 13px; font-weight: 600; }
.vnc-container-fill {
  flex: 1;
  height: auto;
  min-height: 0;
}
.vnc-container-fill:fullscreen { height: 100vh; }

body.popup-mode .topbar,
body.popup-mode .sidebar { display: none; }
body.popup-mode .view {
  margin-left: 0;
  padding: 0;
  max-height: 100dvh;
  overflow: hidden;
}

/* ----- versions library ----- */
.dropzone {
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  background: var(--color-panel-alt);
  color: var(--color-text-dim);
  transition: all 0.15s;
}
.dropzone.is-drag {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.05);
  color: var(--color-primary);
}
.dropzone input[type="file"] { display: none; }
.dropzone label {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

.version-row {
  display: grid;
  grid-template-columns: 120px 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-panel);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.version-row .label { font-weight: 600; }
.version-row .name { color: var(--color-text-dim); font-size: 13px; }
.version-row .size { font-size: 12px; color: var(--color-text-faint); }
.version-row .when { font-size: 12px; color: var(--color-text-faint); }

/* ----- modal ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--color-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.modal-head h3 {
  font-size: 16px;
  font-weight: 600;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--color-text-dim);
  padding: 4px 8px;
  font-size: 20px;
  line-height: 1;
}
.modal-close:hover { color: var(--color-text); background: var(--color-panel-alt); }

/* ----- history table ----- */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-panel-alt);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.history-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover { background: var(--color-panel-alt); }
.history-when {
  white-space: nowrap;
  color: var(--color-text-dim);
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12px;
}
.history-details {
  max-width: 420px;
  word-break: break-word;
}

/* ----- server console ----- */
.console-line { padding: 1px 0; }
.console-error { color: #f87171; }
.console-warn { color: #fbbf24; }

/* ----- utility ----- */
.loading { color: var(--color-text-faint); font-style: italic; padding: 14px; }
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--color-text-faint);
}
