/* Print Management — visual language matches /phone, /pdm, /estimator. */

:root {
  --blue:        #006496;
  --blue-dark:   #004d73;
  --blue-darker: #003752;
  --blue-light:  #3498db;
  --text:        #2c2c2c;
  --muted:       #6b6b6b;
  --muted-2:     #9a9a9a;
  --bg:          #f5f5f5;
  --card:        #ffffff;
  --border:      #dddddd;
  --row-hover:   #fafafa;
  --error-bg:    #f8d7da;
  --error-bd:    #f5c6cb;
  --error-fg:    #721c24;
  --success-bg:  #d4edda;
  --success-bd:  #c3e6cb;
  --success-fg:  #155724;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
}

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

/* ---------- Top nav ---------- */

.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 50px;
  background-color: var(--blue);
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }

.nav-logo { height: 30px; width: auto; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-link {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 3px;
}
.nav-link:hover { color: white; text-decoration: none; background: rgba(255,255,255,0.08); }
.nav-link.is-active { color: white; background: rgba(255,255,255,0.14); }

.nav-user {
  color: #cfe7f4;
  font-size: 13px;
  padding: 5px 10px;
  border-left: 1px solid var(--blue-dark);
}

.nav-logout-form { margin: 0; }
.nav-logout {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.nav-logout:hover { background-color: var(--blue-dark); }

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

.main-content {
  max-width: 880px;
  margin: 24px auto;
  padding: 0 20px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  background-color: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.btn:hover:not(:disabled) { background-color: #f3f3f3; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background-color: var(--blue);
  border-color: var(--blue);
  color: white;
}
.btn-primary:hover:not(:disabled) { background-color: var(--blue-dark); border-color: var(--blue-dark); }

.btn-danger {
  background-color: #e74c3c;
  border-color: #e74c3c;
  color: white;
}
.btn-danger:hover:not(:disabled) { background-color: #c0392b; border-color: #c0392b; }

.btn-link {
  background: transparent;
  border: none;
  color: var(--blue);
  padding: 8px 4px;
  cursor: pointer;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; background: transparent; }

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

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

.login-body { background-color: var(--bg); }

.login-container {
  display: flex;
  justify-content: center;
  padding: 60px 20px 20px;
}

.login-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  max-width: 420px;
}

.login-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
}
.login-header h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.login-header p  { margin: 0; color: var(--muted); font-size: 13px; }

.login-body-inner {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  background-color: #2f2f2f;
  color: white;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s;
}
.btn-microsoft:hover { background-color: #1a1a1a; text-decoration: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.email-login {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--muted); }
.field input {
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
}

.email-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-msg { font-size: 13px; min-height: 18px; }
.form-msg.is-error { color: var(--error-fg); }
.form-msg.is-info  { color: var(--muted); }
.form-msg.is-success { color: var(--success-fg); }

.login-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.error-message {
  background-color: var(--error-bg);
  border: 1px solid var(--error-bd);
  color: var(--error-fg);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
}

/* ---------- Printers list ---------- */

.printers-page,
.admin-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.printers-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.printers-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.help { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.advanced-toggle input { margin: 0; cursor: pointer; }

.printer-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.printer-list .empty {
  background-color: var(--card);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.printer-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.printer-row:hover {
  border-color: #c5c5c5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.printer-row-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.p-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eef5fa;
  color: var(--blue-darker);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.p-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.p-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  cursor: text;
  outline: none;
  border-radius: 3px;
  padding: 1px 4px;
  margin: -1px -4px;
  user-select: none;
  word-break: break-word;
  align-self: flex-start;
}
.p-title.editing {
  background: #fff8d6;
  user-select: text;
  outline: 2px solid var(--blue-light);
}
.p-title.is-ip {
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.p-sub {
  font-size: 12px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.p-model {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.p-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 4px;
}
.p-meta-row .cap {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: #f0f4f7;
  color: var(--text);
  border: 1px solid #e3eaee;
}
.p-meta-row .loc { display: inline-flex; align-items: center; gap: 3px; }

.p-actions-secondary {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.p-admin-link { font-size: 12px; }
.p-cred-state { font-size: 11px; color: var(--muted); }

.p-services {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 0;
}
.p-services .tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #eef5fa;
  color: var(--blue-darker);
  border: 1px solid #d6e7f1;
}
.p-services .tag-installed {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: var(--success-bd);
}
.p-services .tag-warming {
  background: #fff3cd;
  color: #806100;
  border-color: #ffe9a8;
}
.p-services .tag-warming::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 2px solid rgba(128, 97, 0, 0.25);
  border-top-color: #806100;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 5px;
  vertical-align: -1px;
}

/* ---------- Upload card ---------- */

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.upload-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--blue-darker);
  background: #f3f9fc;
  border: 1px dashed #b9d8e8;
  border-radius: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-file:hover {
  background: #e6f1f7;
  border-color: var(--blue-light);
  color: var(--blue);
}
.btn-file.has-file {
  background: var(--success-bg);
  border: 1px solid var(--success-bd);
  border-style: solid;
  color: var(--success-fg);
}
.btn-file svg { flex-shrink: 0; }
.btn-file > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-ghost {
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn-ghost:hover:not(:disabled) {
  background: #f3f3f3;
  border-color: #c5c5c5;
}
.btn-ghost:disabled { opacity: .55; cursor: not-allowed; }

.upload-middle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.paper-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.more-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  display: block;
  margin-bottom: 6px;
}
.paper-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: all 0.12s;
}
.chip:hover { background: #f3f3f3; border-color: #b8b8b8; }
.chip.is-selected {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}
.chip.is-selected:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.more-toggle { margin-left: auto; }

.more-options {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.more-section { display: block; }

.upload-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-print {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  margin-left: auto;
}

.p-status {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}
.p-status.is-error { color: var(--error-fg); }
.p-status.is-success { color: var(--success-fg); }

.btn-spinner, .rescan-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}
.btn-spinner:not([hidden]),
.rescan-spinner:not([hidden]) { display: inline-block; }
.rescan-spinner {
  border-color: var(--border);
  border-top-color: var(--blue);
}
[hidden] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

.scan-summary {
  text-align: right;
  font-size: 12px;
  color: var(--muted-2);
  margin: 4px 0 0;
}

.add-printer-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
}
.add-printer-form input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.add-printer-form input:focus { outline: none; border-color: var(--blue); }

.p-bottom-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-link-danger { color: var(--error-fg); }
.btn-link-danger:hover { color: #531720; text-decoration: underline; }

.p-cred-state {
  font-size: 11px;
  color: var(--muted);
}

.modal-card-narrow {
  width: min(440px, 92vw);
  height: auto;
  max-height: 90vh;
}
.modal-body-padded {
  flex: none;
  padding: 16px 20px 18px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-body-padded .field { gap: 4px; }
.modal-body-padded .field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.modal-body-padded .field input:focus { outline: none; border-color: var(--blue); }
.modal-body-padded .help { margin: 0; font-size: 12px; color: var(--muted); }

.ignored-section {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
}
.ignored-section summary {
  cursor: pointer;
  color: var(--muted);
}
.ignored-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ignored-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 4px 4px;
}
.ignored-ip { font-variant-numeric: tabular-nums; }
.ignored-reason { color: var(--muted-2); font-size: 12px; }

/* ---------- Print options panel ---------- */

.options-panel {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px 12px;
  margin: 6px 0 0;
  background: #fafbfc;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  text-align: left;
}
.options-panel legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 0 4px;
}
.options-panel .opt {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.options-panel .opt > span { font-size: 11px; color: var(--muted); }
.options-panel select,
.options-panel input[type=text],
.options-panel input[type=number] {
  font-size: 13px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: white;
  font-family: inherit;
  color: var(--text);
}
.options-panel select:focus,
.options-panel input:focus {
  outline: none;
  border-color: var(--blue);
}
.options-panel .opt-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  grid-column: 1 / -1;
}
.options-panel .opt-check span { font-size: 12px; color: var(--text); }

/* ---------- Preview modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.modal-card {
  position: relative;
  width: min(900px, 92vw);
  height: min(86vh, 1000px);
  background: white;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-body {
  flex: 1;
  position: relative;
  background: #f0f0f0;
}
#preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}
.preview-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 700px) {
  .printer-row-header { grid-template-columns: auto 1fr; }
  .p-actions-secondary { grid-column: 1 / -1; align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .options-panel { grid-template-columns: 1fr; }
  .upload-top { flex-direction: column; align-items: stretch; }
  .btn-file, .btn-ghost { width: 100%; }
  .more-toggle { margin-left: 0; }
}

/* Advanced-mode gate. Elements with .adv-only are hidden unless the user
   has opted into advanced mode via the checkbox at the top. */
body:not(.advanced) .adv-only { display: none !important; }

/* ---------- Admin ---------- */

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

.add-email-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.add-email-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.add-email-form input:focus { outline: none; border-color: var(--blue); }

.email-list { list-style: none; margin: 0; padding: 0; }
.email-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.email-row:last-child { border-bottom: none; }
.email-list .empty {
  color: var(--muted);
  font-style: italic;
  padding: 14px 4px;
}
.email-addr { font-variant-numeric: tabular-nums; }
.email-meta { color: var(--muted-2); font-size: 12px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: 4px;
  font-size: 13px;
  background-color: #333;
  color: white;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  max-width: 420px;
  z-index: 50;
}
.toast.toast-success { background-color: #2e7d32; }
.toast.toast-error   { background-color: #c0392b; }

/* ---------- Error page ---------- */

.error-page {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 40px;
  text-align: center;
}
.error-page h1 { margin-top: 0; font-size: 22px; }
