/* ============================================================
   App / Studio styles — white-theme, ported from pracownia.
   ============================================================ */

/* ===== STUDIO SHELL ===== */
.studio-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
  min-height: calc(100vh - var(--topbar-h) - var(--topbar-sub-h) - 200px);
}

.studio-sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: calc(var(--topbar-h) + var(--topbar-sub-h) + 16px);
  align-self: start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.ssb-link {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.ssb-link:hover { background: var(--bg-alt); color: var(--text); }
.ssb-link.active { background: var(--text); color: #fff; }

.studio-content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.studio-header { margin-bottom: 8px; }
.studio-header h1 { font-size: 32px; font-weight: 900; letter-spacing: -0.03em; margin-bottom: 4px; }
.studio-header .muted { color: var(--text-3); font-size: 14.5px; }
.studio-header .hist-search {
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-pill);
  font-size: 14px;
  width: 320px; max-width: 100%;
}

/* Dashboard */
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { padding: 20px; }
.stat-card .stat-label { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 900; letter-spacing: -0.02em; }
.dash-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }
.dash-section-title { font-size: 18px; font-weight: 800; margin-top: 16px; margin-bottom: 8px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty-state p { margin-bottom: 16px; }

/* History */
.history-table {
  display: flex; flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-row {
  display: grid;
  grid-template-columns: 1.2fr 2fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 14px;
}
.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: var(--bg-alt); }
.history-head { background: var(--bg-alt); font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.hr-desc { font-weight: 600; }
.hr-date, .hr-len, .hr-items, .hr-cost { color: var(--text-2); }
.hr-cost { font-weight: 700; text-align: right; }

/* Subscription */
.sub-status {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.sub-status.sub-trial { background: rgba(255,159,10,0.12); color: var(--orange); }
.sub-status.sub-active { background: rgba(0,210,106,0.12); color: var(--green); }
.sub-status.sub-expired, .sub-status.sub-cancelled { background: rgba(255,59,48,0.12); color: var(--red); }
.sub-row {
  display: flex; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.sub-row:last-of-type { border-bottom: 0; margin-bottom: 16px; }
.sub-row span { color: var(--text-3); font-weight: 600; }
.sub-row strong { color: var(--text); font-weight: 700; }

/* Settings */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-actions { display: flex; justify-content: flex-end; padding-top: 12px; }
.card h3 { font-size: 16px; font-weight: 800; margin-bottom: 16px; letter-spacing: -0.01em; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fff;
}
.dropzone:hover { border-color: var(--text); background: var(--bg-soft); }
.dropzone.drag { border-color: var(--blue); background: rgba(10,132,255,0.04); }
.dz-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.dz-sub { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }

/* Bulk controls */
.bulk-controls {
  display: flex; flex-wrap: wrap; gap: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.bc-item { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 140px; }
.bc-item label { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.bc-item input {
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.bc-item button { align-self: flex-start; }

/* File list */
.file-list { display: flex; flex-direction: column; gap: 12px; }
.file-row {
  display: grid;
  grid-template-columns: 72px 1fr auto auto;
  gap: 16px; align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.file-thumb {
  width: 72px; height: 72px;
  background: var(--bg-alt) repeating-conic-gradient(#fff 0deg 90deg, #f0f0f0 90deg 180deg) 0 0/12px 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.file-thumb img { width: 100%; height: 100%; object-fit: contain; }
.file-info { min-width: 0; }
.file-name {
  font-weight: 700;
  font-size: 14.5px;
  display: flex; align-items: center;
  margin-bottom: 4px;
  word-break: break-word;
}
.file-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text); color: #fff;
  font-size: 11px; font-weight: 800;
  margin-right: 8px;
  flex-shrink: 0;
}
.file-meta { font-size: 12.5px; color: var(--text-3); }
.dpi-warn {
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}
.dpi-bad { background: rgba(255,59,48,0.08); border: 1px solid rgba(255,59,48,0.25); color: var(--red); }
.dpi-mid { background: rgba(255,159,10,0.08); border: 1px solid rgba(255,159,10,0.25); color: var(--orange); }
.trim-info { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.file-controls {
  display: flex; gap: 8px; align-items: flex-end;
}
.file-controls > div { display: flex; flex-direction: column; gap: 4px; }
.file-controls label { font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.file-controls input {
  width: 70px;
  padding: 8px 10px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.dim-x { color: var(--text-3); font-weight: 800; align-self: center; padding-top: 14px; }
.file-remove {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--text-3);
  font-size: 22px;
  font-weight: 300;
  align-self: flex-start;
}
.file-remove:hover { background: var(--red); color: #fff; }

/* Roll section */
.roll-section { display: flex; flex-direction: column; gap: 16px; }
.roll-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.stat {
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.stat-value { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; color: var(--text); }

.roll-canvas-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: auto;
  max-height: 80vh;
  box-shadow: var(--shadow-sm);
}
.roll-canvas {
  position: relative;
  background:
    repeating-conic-gradient(#eaeaea 0deg 90deg, #fff 90deg 180deg) 0 0/14px 14px;
  border-radius: 4px;
}
.roll-label {
  position: absolute; left: 0;
  background: rgba(0,210,106,0.05);
  border-bottom: 1.5px dashed rgba(0,210,106,0.3);
  display: flex; align-items: center;
  gap: 4px;
  z-index: 15;
  overflow: hidden;
}
.roll-label-1 { font-size: 10px; font-weight: 800; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roll-label-2 { font-size: 9px; font-weight: 600; color: rgba(0,210,106,0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.roll-edge { position: absolute; top: 0; width: 2px; background: #C0C0C0; opacity: 0.7; z-index: 10; }
.roll-margin { position: absolute; background: rgba(255,59,48,0.06); z-index: 5; }
.roll-item {
  position: absolute;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  outline: 1px solid rgba(0,0,0,0.08);
  border-radius: 2px;
}
.roll-item-num {
  position: absolute;
  bottom: 2px; right: 3px;
  background: var(--text); color: #fff;
  font-size: 9px; font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  z-index: 20;
}
.roll-item-dim {
  position: absolute;
  top: 2px; left: 3px;
  background: rgba(255,255,255,0.85);
  color: var(--red);
  font-size: 8px; font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  z-index: 20;
  pointer-events: none;
}
.roll-demo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 900;
  color: rgba(255,42,42,0.2);
  transform: rotate(-30deg);
  pointer-events: none;
  z-index: 30;
}

.generate-actions {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 8px 0;
  justify-content: center;
}

/* Responsive */
@media (max-width: 900px) {
  .studio-shell { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .studio-sidebar {
    flex-direction: row;
    overflow-x: auto;
    position: relative; top: auto;
    padding: 6px;
  }
  .ssb-link { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .file-row { grid-template-columns: 60px 1fr auto; }
  .file-thumb { width: 60px; height: 60px; }
  .file-controls { grid-column: 1 / -1; }
  .file-remove { position: absolute; top: 8px; right: 8px; }
}

/* ============================================================
   v2: mode tabs + sheet presets + promo input + admin link
   + AI support widget
   ============================================================ */
.mode-tabs { display:flex; gap:8px; margin-bottom:20px; }
.mode-tab {
  padding:12px 24px; border-radius:var(--radius-pill);
  font-weight:800; font-size:14px;
  border:2px solid var(--border-2);
  background:transparent; color:var(--text-2);
  cursor:pointer; transition:all .2s; font-family:inherit;
}
.mode-tab.active { background:var(--text); color:#fff; border-color:var(--text); }
.mode-tab:hover:not(.active) { border-color:var(--text); color:var(--text); }
.sheet-presets {
  display:flex; align-items:center; gap:8px;
  margin-bottom:16px; flex-wrap:wrap;
}
.sheet-presets span {
  font-size:12px; font-weight:800;
  color:var(--text-3); letter-spacing:0.04em; text-transform:uppercase;
}

/* Promo redemption input on subscription page */
.promo-input { display:flex; gap:8px; margin-top:16px; }
.promo-input input {
  flex:1;
  padding:12px 14px;
  border:1px solid var(--border-2);
  border-radius:var(--radius-sm);
  font-size:14px; font-weight:700; letter-spacing:0.05em;
}
.promo-input input:focus { outline:none; border-color:var(--blue); box-shadow:0 0 0 4px rgba(10,132,255,0.12); }
.promo-pending, .promo-ok, .promo-err {
  margin-top:10px; padding:10px 14px; border-radius:var(--radius-sm);
  font-size:13px; font-weight:600;
}
.promo-pending { background:var(--bg-alt); color:var(--text-3); }
.promo-ok { background:rgba(0,210,106,0.1); color:var(--green); border:1px solid rgba(0,210,106,0.25); }
.promo-err { background:rgba(255,59,48,0.1); color:var(--red); border:1px solid rgba(255,59,48,0.25); }

/* Admin-only sidebar link styling */
.ssb-admin {
  margin-top:8px;
  border-top:1px solid var(--border);
  padding-top:14px !important;
  color:var(--accent) !important;
  font-weight:800 !important;
}
.ssb-admin.active { background:var(--accent) !important; color:#fff !important; border-top-color:transparent; }

/* ============== AI SUPPORT WIDGET ============== */
.support-fab {
  position:fixed; bottom:24px; right:24px;
  width:56px; height:56px;
  border-radius:50%;
  background:var(--text); color:#fff;
  font-size:24px; border:none; cursor:pointer;
  box-shadow:var(--shadow-lg); z-index:9999;
  transition:transform .2s, background .2s;
}
.support-fab:hover { transform:scale(1.08); background:var(--accent); }
.support-panel {
  position:fixed; bottom:92px; right:24px;
  width:380px; max-width:calc(100vw - 32px); max-height:560px;
  background:#fff;
  border-radius:16px;
  box-shadow:var(--shadow-xl);
  border:1px solid var(--border);
  z-index:9999;
  display:flex; flex-direction:column; overflow:hidden;
  animation:sp-in .25s ease;
}
.support-panel.hidden { display:none; }
.support-panel.drag { border-color:var(--blue); box-shadow:0 0 0 4px rgba(10,132,255,0.18), var(--shadow-xl); }
@keyframes sp-in { from { opacity:0; transform:translateY(20px) scale(0.96); } to { opacity:1; transform:translateY(0) scale(1); } }
.sp-header {
  padding:14px 18px;
  background:var(--bg-alt);
  border-bottom:1px solid var(--border);
  display:flex; justify-content:space-between; align-items:center;
  font-weight:800; font-size:14px;
}
.sp-header button {
  width:28px; height:28px; border-radius:50%;
  background:transparent; color:var(--text-3);
  font-size:22px; line-height:1; cursor:pointer; font-family:inherit;
}
.sp-header button:hover { background:#fff; color:var(--text); }
.sp-messages {
  flex:1; overflow-y:auto;
  padding:16px;
  display:flex; flex-direction:column; gap:10px;
  min-height:120px; max-height:340px;
}
.sp-msg {
  padding:10px 14px;
  border-radius:14px;
  font-size:13.5px; line-height:1.5;
  max-width:88%; word-wrap:break-word;
}
.sp-msg.user {
  background:var(--text); color:#fff;
  margin-left:auto; border-bottom-right-radius:4px;
}
.sp-msg.ai {
  background:var(--bg-alt); color:var(--text);
  border-bottom-left-radius:4px;
}
.sp-msg.typing { display:flex; gap:4px; padding:14px 16px; }
.sp-msg.typing span {
  width:6px; height:6px; border-radius:50%; background:var(--text-3);
  animation:sp-bounce 1.2s infinite ease-in-out both;
}
.sp-msg.typing span:nth-child(2) { animation-delay:.15s; }
.sp-msg.typing span:nth-child(3) { animation-delay:.3s; }
@keyframes sp-bounce { 0%,80%,100% { transform:scale(0.6); opacity:.4; } 40% { transform:scale(1); opacity:1; } }
.sp-msg-file { margin-top:8px; max-width:100%; max-height:200px; border-radius:8px; display:block; }
.sp-msg-link { display:block; margin-top:6px; color:var(--blue); font-weight:600; text-decoration:none; }
.sp-input {
  padding:10px 12px;
  border-top:1px solid var(--border);
  display:flex; gap:8px; align-items:flex-end;
}
.sp-input textarea {
  flex:1; resize:none;
  border:1px solid var(--border-2);
  border-radius:10px;
  padding:9px 12px;
  font-size:13.5px; font-family:inherit;
  max-height:120px;
}
.sp-input textarea:focus { outline:none; border-color:var(--blue); box-shadow:0 0 0 3px rgba(10,132,255,0.12); }
.sp-attach {
  cursor:pointer; font-size:20px;
  padding:6px 8px; border-radius:8px;
  transition:background .2s; align-self:center;
}
.sp-attach:hover { background:var(--bg-alt); }
.sp-input .btn-sm {
  padding:8px 14px;
  border-radius:10px;
  font-size:14px; line-height:1;
}
#spAttachPreview { padding:0 12px; }
.sp-attach-row {
  display:flex; align-items:center; gap:8px;
  margin:8px 0 4px;
  padding:6px 10px;
  background:var(--bg-alt);
  border-radius:10px;
}
.sp-file-preview { max-height:80px; max-width:60%; border-radius:6px; }
.sp-file-name { flex:1; font-size:12px; font-weight:600; color:var(--text-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sp-attach-rm {
  width:24px; height:24px; border-radius:50%;
  background:#fff; color:var(--text-3);
  font-size:16px; cursor:pointer;
}
.sp-attach-rm:hover { background:var(--red); color:#fff; }

@media (max-width:600px) {
  .support-panel { right:8px; left:8px; bottom:80px; width:auto; max-height:calc(100vh - 100px); }
  .support-fab { right:16px; bottom:16px; }
}

/* ============================================================
   v3: dealer admin (tier select) + activation key input
   ============================================================ */
.dealer-tier-select {
  padding:6px 10px; border-radius:8px;
  border:1px solid var(--border-2);
  font-size:12px; font-weight:700;
  background:#fff; text-transform:capitalize;
}
