/* Palette matches web/print-from-anywhere/index.html so the two hosted
   pages (app.bluetoothprinter.in and printbridge.bluetoothprinter.in) read as one
   product family. */
:root {
  --primary: #2C5050;
  --primary-dark: #182C2C;
  --accent: #FF4081;
  --accent-2: #FF7CA3;
  --success: #4CAF50;
  --error: #FF5252;
  --bg: #0F1E1E;
  --card: #1F3838;
  --card-2: #223D3D;
  --border: #2E4F4F;
  --text: #FFFFFF;
  --text-muted: #B2CCCC;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --radius: 14px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; }
::selection { background: var(--accent); color: white; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(720px circle at 12% -10%, rgba(255, 64, 129, 0.08), transparent 60%),
    radial-gradient(900px circle at 100% 0%, rgba(44, 80, 80, 0.35), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 64px;
  -webkit-font-smoothing: antialiased;
}
/* Thin, theme-matched scrollbar for the log/preview panes and Firefox generally. */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.container { width: 100%; max-width: 480px; margin: 0 auto; }
.container.wide { max-width: 760px; }
.container.home { max-width: 480px; }

/* --- Home page split layout (Print now + account/MCP side content) --- */
.home-grid { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.home-main, .home-side { width: 100%; min-width: 0; }
@media (min-width: 860px) {
  .container.home { max-width: 1000px; }
  .home-grid { grid-template-columns: 3fr 2fr; }
}
.mcp-instructions { margin-top: 4px; }
#mcpAgentSelect { margin-bottom: 12px; }

/* --- Custom confirm dialog (js/confirm-dialog.js) - replaces the browser's native confirm() --- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 12, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.confirm-dialog {
  background: linear-gradient(165deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 400px;
  width: 100%;
}
.confirm-dialog h3 { margin: 0 0 10px; font-size: 17px; }
.confirm-dialog p { color: var(--text-muted); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions button { padding: 10px 18px; }
.confirm-dialog:has(.confirm-modal-body) { max-width: 480px; }
.confirm-modal-body {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 20px;
  max-height: 50vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.confirm-modal-body img { max-width: 100%; }

h1 {
  font-size: 24px;
  margin: 8px 0 4px;
  letter-spacing: -0.02em;
  color: var(--text);
  display: inline-block;
}
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -0.01em; }
p.subtitle { color: var(--text-muted); margin-top: 0; margin-bottom: 24px; font-size: 14px; line-height: 1.5; }
.card {
  background: linear-gradient(165deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 64, 129, 0.18);
}
textarea { min-height: 100px; resize: vertical; font-family: monospace; }
button {
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
button:active { transform: scale(0.98); }
button.primary {
  background: linear-gradient(135deg, var(--accent), #E91E63);
  color: white;
  width: 100%;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(255, 64, 129, 0.35);
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }
button.secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
button.secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error); }
button.danger:hover:not(:disabled) { background: rgba(255, 82, 82, 0.12); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button { flex: 1; background: var(--card); color: var(--text-muted); border: 1px solid var(--border); }
.tabs button.active { background: var(--accent); color: white; border-color: var(--accent); box-shadow: 0 4px 14px rgba(255, 64, 129, 0.3); }
.hidden { display: none !important; }
.msg { font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.msg.error { background: rgba(255, 82, 82, 0.15); color: var(--error); border: 1px solid var(--error); }
.msg.success { background: rgba(76, 175, 80, 0.15); color: var(--success); border: 1px solid var(--success); }
.key-reveal {
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 10px 0;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: bold; letter-spacing: 0.02em; }
.badge.ok { background: rgba(76, 175, 80, 0.2); color: var(--success); }
.badge.pending { background: rgba(255, 193, 7, 0.2); color: #FFC107; }
.badge.error { background: rgba(255, 82, 82, 0.2); color: var(--error); }
.badge.muted { background: rgba(178, 204, 204, 0.15); color: var(--text-muted); }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}
.topbar-brand { min-width: 0; flex: 1 1 auto; }
.topbar-brand h1 { margin: 0; display: block; }
.topbar-brand .brand-byline { margin: 4px 0 0; }
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
  flex: 0 0 auto;
  margin-top: 4px;
}
.topbar-actions .email {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions button.secondary {
  display: inline-flex;
  align-items: center;
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 0;
  }
  .topbar-actions .email { max-width: 100%; }
}

.api-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.api-key-mask {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.api-key-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.api-key-actions button.secondary {
  display: inline-flex;
  align-items: center;
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 520px) {
  .api-key-row {
    flex-direction: column;
    align-items: stretch;
  }
  .api-key-mask { white-space: normal; word-break: break-all; }
  .api-key-actions { justify-content: flex-end; }
}

a { color: var(--accent-2); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent); text-decoration: underline; }
.empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; text-align: center; }
.brand-byline { color: var(--text-muted); font-size: 12px; margin: 2px 0 24px; }
footer.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
footer.site-footer a { color: var(--text-muted); text-decoration: underline; }
input[type="file"] { width: 100%; color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.rich-line { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; flex-wrap: wrap; }
.rich-line input[type="text"] { margin-bottom: 0; flex: 1 1 140px; min-width: 100px; }
.rich-line select { margin-bottom: 0; width: auto; padding: 8px; }
.rich-line label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin-bottom: 0; white-space: nowrap; }
.rich-line label input[type="checkbox"] { margin: 0; }
.rich-line.divider-line { justify-content: center; color: var(--text-muted); font-size: 12px; }
.rich-line button.danger { padding: 6px 10px; }

/* --- Live server connection indicator (Firebase .info/connected) --- */
.conn-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.conn-dot.connected { background: var(--success); animation: pulse-ring 2s infinite; }
.conn-dot.disconnected { background: var(--error); animation: pulse-fade 1s infinite; }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}
@keyframes pulse-fade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Printer-connected pill (upgrades a plain text status line) --- */
.printer-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; margin: -4px 0 14px; transition: background 0.2s ease, color 0.2s ease; }
.printer-pill.checking { background: rgba(178, 204, 204, 0.1); color: var(--text-muted); }
.printer-pill.connected { background: rgba(76, 175, 80, 0.15); color: var(--success); }
.printer-pill.disconnected { background: rgba(255, 82, 82, 0.15); color: var(--error); }
.printer-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.printer-pill.checking .dot { animation: pulse-fade 1s infinite; }

/* --- Live receipt preview --- */
.receipt-preview { background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.receipt-preview-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.receipt-preview pre { font-family: monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; margin: 0; color: var(--text); max-height: 160px; overflow-y: auto; }

/* --- Activity log (mirrors the app's own Print Bridge screen log) --- */
.log-view {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 14px;
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  color: var(--text-muted);
}

/* --- Step-by-step send progress tracker --- */
.steps { display: flex; justify-content: space-between; margin: 18px 0 8px; position: relative; }
.steps::before { content: ''; position: absolute; top: 9px; left: 8%; right: 8%; height: 2px; background: var(--border); z-index: 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; position: relative; z-index: 1; }
.step-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--bg); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 10px; color: white; transition: background 0.3s ease, border-color 0.3s ease; }
.step-label { font-size: 10px; color: var(--text-muted); text-align: center; }
.step.active .step-dot { border-color: var(--accent); background: var(--accent); animation: pulse-ring-accent 1.2s infinite; }
.step.active .step-label { color: var(--accent); font-weight: bold; }
.step.done .step-dot { border-color: var(--success); background: var(--success); }
.step.done .step-dot::after { content: '\2713'; }
.step.done .step-label { color: var(--success); }
.step.error .step-dot { border-color: var(--error); background: var(--error); }
.step.error .step-dot::after { content: '\2715'; }
.step.error .step-label { color: var(--error); }
@keyframes pulse-ring-accent {
  0% { box-shadow: 0 0 0 0 rgba(255, 64, 129, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(255, 64, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 64, 129, 0); }
}

/* --- Wait progress bar + countdown --- */
.progress-bar { height: 4px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: var(--accent); width: 100%; transition: width 1s linear; }
.countdown { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

/* --- Quick-print compose editor (Quill, "snow" theme) - dark-theme overrides matching this
   page's other inputs, plus the two custom Divider/Attach-image buttons quick-print.js appends
   to the toolbar after init. Scoped to #quickEditor/#quickToolbar (ids quick-print.js assigns -
   #quickEditor keeps its original id, #quickToolbar is assigned in JS since Quill's toolbar div
   otherwise has none) rather than Quill's own .ql-* classes: an id selector's specificity beats
   any of Quill's own class-only selectors outright, so these overrides can't lose a specificity
   tie-break against quill.snow.css regardless of which stylesheet happens to load/parse second -
   that mismatch (Quill's own higher-specificity button-sizing rule beating a same-specificity
   class override) was exactly why the custom toolbar buttons rendered squashed/overlapping. */
#quickToolbar.ql-toolbar {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--bg);
}
#quickEditor.ql-container {
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 15px;
  margin-bottom: 14px;
}
/* min-height keeps it from looking cramped when empty; max-height + overflow-y stop it from
   growing the whole page taller as the user keeps typing - it scrolls internally instead. */
#quickEditor .ql-editor { color: var(--text); min-height: 100px; max-height: 320px; overflow-y: auto; }
#quickEditor .ql-editor.ql-blank::before { color: var(--text-muted); font-style: normal; }
#quickToolbar .ql-stroke { stroke: var(--text-muted); }
#quickToolbar .ql-fill, #quickToolbar .ql-stroke.ql-fill { fill: var(--text-muted); }
#quickToolbar .ql-picker { color: var(--text-muted); }
#quickToolbar .ql-picker-options { background: var(--card); border: 1px solid var(--border) !important; }
#quickToolbar .ql-picker-item:hover, #quickToolbar .ql-picker-label:hover { color: var(--accent); }
#quickToolbar .ql-picker-label:hover .ql-stroke { stroke: var(--accent); }
#quickToolbar button:hover .ql-stroke,
#quickToolbar button.ql-active .ql-stroke { stroke: var(--accent); }
#quickToolbar button:hover, #quickToolbar button.ql-active { color: var(--accent); }
#quickEditor.ql-disabled, #quickToolbar .ql-formats button:disabled { opacity: 0.5; }
#quickToolbar .ql-custom-btn {
  width: auto;
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: normal;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}
#quickToolbar .ql-custom-btn:hover { color: var(--accent); border-color: var(--accent); }

/* --- Attached image chip (shown while an image/PDF is attached, replacing the text editor) --- */
.image-chip { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: -4px 0 14px; font-size: 13px; color: var(--text-muted); }
/* A long filename is one unbreakable string - without min-width:0 a flex child never shrinks
   below its content's natural width, which pushed the Remove button outside the chip (and often
   outside the card entirely) for anything longer than a few characters. */
.image-chip span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-chip button { flex: 0 0 auto; padding: 4px 10px; font-size: 12px; }
