/* ============ CloudPrint ============ */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --text: #1c2333;
  --text-muted: #6b7280;
  --border: #e2e6ee;
  --accent: #3556e0;
  --accent-hover: #2a46c4;
  --accent-soft: #e8edfd;
  --danger: #d64545;
  --success: #1f9d55;
  --warning: #d97706;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b2029;
    --surface-2: #232935;
    --text: #e7eaf0;
    --text-muted: #9aa3b2;
    --border: #2d3442;
    --accent: #5b7bff;
    --accent-hover: #7290ff;
    --accent-soft: #232d4d;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ============ Topbar ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-icon {
  font-size: 26px;
  background: var(--accent-soft);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
}

.brand h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }

.brand-sub { margin: 0; font-size: 12px; color: var(--text-muted); }

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

.printer-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 45vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: color .12s, border-color .12s, background .12s;
}

.logout-link:hover { color: var(--danger); border-color: var(--danger); background: rgba(214, 69, 69, .08); }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.idle { background: var(--success); box-shadow: 0 0 0 3px rgba(31, 157, 85, .18); }
.status-dot.printing { background: var(--warning); animation: pulse 1.2s infinite; }
.status-dot.disabled, .status-dot.error { background: var(--danger); }

@keyframes pulse {
  50% { opacity: .4; }
}

/* ============ Layout ============ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  padding: 20px clamp(16px, 4vw, 32px) 40px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

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

/* ============ Dropzone ============ */

.preview-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.dropzone {
  flex: 1;
  margin: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-icon {
  width: 52px;
  height: 52px;
  color: var(--accent);
  margin-bottom: 14px;
}

.dropzone-title { font-size: 19px; font-weight: 600; margin: 0 0 4px; }

.dropzone-hint { margin: 0; color: var(--text-muted); }

.dropzone-hint .link { color: var(--accent); font-weight: 500; text-decoration: underline; }

.dropzone-formats {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: .03em;
}

.dropzone-progress { display: grid; place-items: center; gap: 10px; color: var(--text-muted); }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

/* ============ Preview ============ */

.preview { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.file-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.file-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.file-text { display: flex; flex-direction: column; min-width: 0; }

.file-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta { font-size: 12px; color: var(--text-muted); }

.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.zoom-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.zoom-level {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
  color: var(--text-muted);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}

.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.icon-btn.danger:hover { background: rgba(214, 69, 69, .12); color: var(--danger); }

.pages-scroll {
  flex: 1;
  overflow: auto;
  background: var(--surface-2);
  padding: 24px;
  max-height: min(72vh, 900px);
}

.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  transition: filter .25s;
}

.pages.grayscale { filter: grayscale(1); }

.page-wrap {
  position: relative;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .18);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  transition: opacity .2s;
  line-height: 0;
}

.page-wrap canvas, .page-wrap img { display: block; max-width: 100%; }

.page-wrap .page-num {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 11px;
  line-height: 1.6;
  background: rgba(28, 35, 51, .72);
  color: #fff;
  padding: 1px 8px;
  border-radius: 999px;
}

.page-wrap.excluded { opacity: .25; }

.page-wrap.excluded::after {
  content: "nu se printează";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.text-preview {
  background: #fff;
  color: #1c2333;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .18);
  padding: 32px;
  width: 100%;
  max-width: 640px;
  min-height: 400px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

/* ============ Options panel ============ */

.options-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 92px;
}

@media (max-width: 900px) {
  .options-card { position: static; }
}

.panel-title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }

/* Presets */

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color .12s, background .12s, transform .08s;
  text-align: center;
}

.preset:hover { border-color: var(--accent); }

.preset:active { transform: scale(.97); }

.preset.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.preset-icon { font-size: 20px; }

.preset-name { font-size: 12px; font-weight: 600; }

.preset-desc { font-size: 10px; color: var(--text-muted); line-height: 1.3; }

/* Fields */

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

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

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

.field .muted { text-transform: none; font-weight: 400; letter-spacing: 0; }

select, input[type="text"], input[type="number"] {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}

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

input.invalid { border-color: var(--danger); }

.field-error { margin: 0; font-size: 12px; color: var(--danger); }

/* Segmented control */

.segmented {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.segmented button {
  flex: 1;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .15);
}

/* Stepper */

.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  width: fit-content;
}

.stepper button {
  width: 42px;
  font-size: 18px;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}

.stepper button:hover { background: var(--accent-soft); color: var(--accent); }

.stepper input {
  width: 56px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  font-weight: 600;
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Advanced */

.advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.advanced summary {
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.advanced summary::-webkit-details-marker { display: none; }

.advanced summary::after { content: "▾"; transition: transform .15s; }

.advanced[open] summary::after { transform: rotate(180deg); }

.advanced-body {
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }

/* Print button */

.print-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  transition: background .12s, transform .08s, opacity .12s;
  box-shadow: 0 4px 14px -4px var(--accent);
}

.print-btn:hover:not(:disabled) { background: var(--accent-hover); }

.print-btn:active:not(:disabled) { transform: scale(.98); }

.print-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* Jobs */

.jobs h3 {
  margin: 4px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.jobs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.jobs li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.jobs .job-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jobs .job-cancel {
  color: var(--text-muted);
  font-size: 15px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.jobs .job-cancel:hover { background: rgba(214, 69, 69, .12); color: var(--danger); }

/* ============ Toasts ============ */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

.toast.leaving { animation: toast-out .25s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(12px); }
}

/* ============ Tabs ============ */

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 clamp(16px, 4vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 75px;
  z-index: 15;
  overflow-x: auto;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}

.tab:hover { color: var(--text); }

.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-icon { font-size: 15px; }

.tab-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

/* ============ Boards (Fișiere / Istoric) ============ */

.board {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 32px) 48px;
}

.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.board-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }

.board-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }

.ghost-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: color .12s, border-color .12s;
}

.ghost-btn:hover { color: var(--danger); border-color: var(--danger); }

/* Empty states */

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 40px; display: block; margin-bottom: 12px; opacity: .7; }

.empty-state p { margin: 0 0 12px; font-size: 15px; }

/* History list */

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.history-badge {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--surface-2);
}

.history-body { flex: 1; min-width: 0; }

.history-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============ Login ============ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.login-brand h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }

.login-error {
  background: rgba(214, 69, 69, .1);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}

.login-card .print-btn { margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
