/* === LEGENDARIO STUDIO PLATFORM (WEB3 ELEGANCE + APPLE SMOOTHNESS) === */
:root {
  --p-bg: #07090D;
  --p-surface: #0D1119;
  --p-elevated: #131926;
  --p-border: rgba(148, 163, 184, 0.14);
  --p-border-hi: rgba(255, 94, 26, 0.42);
  --p-text: #F1F5F9;
  --p-muted: #8B97AD;
  --p-orange: #FF5E1A;
  --p-orange-soft: rgba(255, 94, 26, 0.14);
  --p-blue: #7AA2F7;
  --p-green: #10B981;
  --p-amber: #F59E0B;
  --p-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body {
  background: var(--p-bg);
  color: var(--p-text);
  scrollbar-width: none;
}
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* Topbar global persistente */
.plat-topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  height: 54px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 17, 25, 0.96);
  border-bottom: 1px solid var(--p-border);
}

.plat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.plat-brand__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(255, 94, 26, 0.35);
}

.plat-brand__name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.plat-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
}

.plat-nav__btn {
  border: 0;
  background: transparent;
  color: var(--p-muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms var(--p-ease);
}

.plat-nav__btn:hover { color: var(--p-text); }
.plat-nav__btn.is-active {
  background: var(--p-elevated);
  color: var(--p-text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

#platformRoot {
  display: flex;
  flex-direction: column;
  width: 100vw;
  position: relative;
}

.plat-view {
  contain: layout style;
  animation: platFadeIn 280ms var(--p-ease) both;
}
.plat-view[hidden] {
  display: none !important;
  content-visibility: hidden !important;
}

#view-hub,
#view-crm,
#view-vault {
  flex: 1;
  min-height: 0;
  height: calc(100vh - 54px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar sutil estilo macOS para as views com rolagem vertical */
#view-hub::-webkit-scrollbar,
#view-crm::-webkit-scrollbar,
#view-vault::-webkit-scrollbar {
  display: block;
  width: 6px;
}
#view-hub::-webkit-scrollbar-track,
#view-crm::-webkit-scrollbar-track,
#view-vault::-webkit-scrollbar-track {
  background: transparent;
}
#view-hub::-webkit-scrollbar-thumb,
#view-crm::-webkit-scrollbar-thumb,
#view-vault::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.16);
  border-radius: 999px;
}
#view-hub::-webkit-scrollbar-thumb:hover,
#view-crm::-webkit-scrollbar-thumb:hover,
#view-vault::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.32);
}

#view-editor,
#view-svg {
  flex: 1;
  min-height: 0;
  height: calc(100vh - 54px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#view-editor .workspace {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  padding: 8px 12px 12px;
  gap: 12px;
  overflow: hidden;
}

#view-editor .stage {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Oculta os botões duplicados de janela no sub-header do editor */
#view-editor .topbar .window-controls,
#view-editor .topbar .window-controls-divider {
  display: none !important;
}

#view-editor .topbar {
  height: 42px;
  min-height: 42px;
  background: rgba(5, 10, 22, 0.75);
}

#view-editor .projects-bar {
  min-height: 34px;
}

@keyframes platFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* === HUB LAUNCHER === */
.plat-hub {
  max-width: 1140px;
  margin: 0 auto;
  padding: 56px 28px 64px;
}

.plat-hub__eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--p-orange);
  font-weight: 600;
  margin-bottom: 10px;
}

.plat-hub__title {
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.plat-hub__sub {
  font-size: 15px;
  color: var(--p-muted);
  margin: 0 0 38px;
}

.plat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
}

.plat-tile {
  position: relative;
  text-align: left;
  padding: 26px 24px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(19, 25, 38, 0.85), rgba(13, 17, 25, 0.95));
  border: 1px solid var(--p-border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 240ms var(--p-ease), border-color 240ms var(--p-ease), box-shadow 260ms var(--p-ease);
}

.plat-tile:hover {
  transform: translateY(-4px);
  border-color: var(--p-border-hi);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 94, 26, 0.12);
}

.plat-tile__ico {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--p-orange-soft);
  color: var(--p-orange);
  border: 1px solid rgba(255, 94, 26, 0.25);
}

.plat-tile__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--p-text);
  letter-spacing: -0.01em;
}

.plat-tile__desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--p-muted);
}

.plat-tile__meta {
  margin-top: auto;
  padding-top: 10px;
  font-size: 11.5px;
  color: var(--p-blue);
  font-weight: 500;
}

/* === CRM & VAULT === */
.crm-shell {
  padding: 22px 24px 36px;
  height: calc(100vh - 54px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}

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

.crm-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.p-input, .p-select, .p-textarea {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  color: var(--p-text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 180ms var(--p-ease);
}
.p-input:focus, .p-select:focus, .p-textarea:focus {
  border-color: var(--p-orange);
}

.p-btn {
  border: 1px solid var(--p-border);
  background: var(--p-elevated);
  color: var(--p-text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 180ms var(--p-ease);
}
.p-btn:hover { border-color: rgba(148, 163, 184, 0.35); }
.p-btn--primary {
  background: linear-gradient(135deg, #FF7A2F, #FF5E1A);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.p-btn--primary:hover { filter: brightness(1.08); }
.p-btn--danger { color: #FCA5A5; border-color: rgba(239, 68, 68, 0.3); }

/* Kanban 6 colunas */
.crm-board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(230px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.crm-col {
  background: rgba(13, 17, 25, 0.72);
  border: 1px solid var(--p-border);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.crm-col__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--p-text);
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--p-border);
}

.crm-col__count {
  font-size: 11px;
  color: var(--p-muted);
  background: var(--p-elevated);
  padding: 2px 8px;
  border-radius: 999px;
}

.crm-col__list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-card {
  background: var(--p-elevated);
  border: 1px solid var(--p-border);
  border-radius: 12px;
  padding: 12px;
  cursor: grab;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 180ms var(--p-ease), border-color 180ms var(--p-ease), opacity 160ms var(--p-ease);
}
.crm-card:active {
  cursor: grabbing;
}
.crm-card.is-dragging {
  opacity: 0.45;
  transform: scale(0.96);
  border-color: var(--p-orange);
}
.crm-col.is-drag-over {
  background: rgba(255, 94, 26, 0.08) !important;
  border-color: var(--p-orange) !important;
  box-shadow: 0 0 24px rgba(255, 94, 26, 0.25);
}
.crm-col.is-drop-flash {
  animation: dropFlash 420ms var(--p-ease);
}
@keyframes dropFlash {
  0% { border-color: #10B981; box-shadow: 0 0 24px rgba(16, 185, 129, 0.4); }
  100% { border-color: var(--p-border); box-shadow: none; }
}

.crm-card__project-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(122, 162, 247, 0.12);
  border: 1px solid rgba(122, 162, 247, 0.28);
  color: var(--p-blue);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 500;
  margin-top: 2px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-linked-box {
  background: rgba(19, 25, 38, 0.6);
  border: 1px solid var(--p-border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.crm-linked-box__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.btn-link-client {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 94, 26, 0.12);
  border: 1px solid rgba(255, 94, 26, 0.3);
  color: #FF9A3C;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 180ms var(--p-ease);
  user-select: none;
}
.btn-link-client:hover {
  background: rgba(255, 94, 26, 0.22);
  border-color: #FF5E1A;
  color: #FFF;
  transform: translateY(-1px);
}
.btn-link-client.is-linked {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34D399;
}

/* Toasts de Feedback Tranquilizador */
.plat-toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.plat-toast {
  background: rgba(13, 17, 25, 0.96);
  border: 1px solid rgba(16, 185, 129, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 16px rgba(16, 185, 129, 0.18);
  color: #F1F5F9;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastSlideDown 240ms var(--p-ease) both;
}
.plat-toast--info {
  border-color: rgba(122, 162, 247, 0.45);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 28px rgba(122, 162, 247, 0.22);
}
.plat-toast__icon {
  font-size: 15px;
  color: #10B981;
}
.plat-toast--info .plat-toast__icon {
  color: #7AA2F7;
}
@keyframes toastSlideDown {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.crm-card:hover {
  transform: translateY(-2px);
  border-color: var(--p-border-hi);
}
.crm-card__name { font-size: 13.5px; font-weight: 600; color: var(--p-text); }
.crm-card__niche { font-size: 11.5px; color: var(--p-muted); }
.crm-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--p-muted);
  margin-top: 4px;
}
.crm-stars { color: #FBBF24; letter-spacing: 1px; }

/* Drawer Lateral da Ficha do Cliente */
.crm-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(3, 5, 10, 0.82);
  display: flex;
  justify-content: flex-end;
}
.crm-drawer-backdrop[hidden] { display: none !important; }

.crm-drawer {
  width: min(560px, 94vw);
  height: 100%;
  background: var(--p-surface);
  border-left: 1px solid var(--p-border);
  padding: 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  animation: drawerSlide 260ms var(--p-ease) both;
}

@keyframes drawerSlide {
  from { transform: translateX(36px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.crm-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--p-orange);
  font-weight: 600;
  margin-top: 6px;
}

.crm-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.crm-field { display: flex; flex-direction: column; gap: 5px; }
.crm-field--full { grid-column: 1 / -1; }
.crm-field label { font-size: 11.5px; color: var(--p-muted); }

.crm-inline {
  display: flex;
  gap: 6px;
  align-items: center;
}
.crm-inline .p-input { flex: 1; min-width: 0; }

/* Cofre de Prompts */
.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding-bottom: 12px;
}
.vault-card {
  background: var(--p-elevated);
  border: 1px solid var(--p-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.vault-card pre {
  margin: 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--p-muted);
  white-space: pre-wrap;
  max-height: 110px;
  overflow: hidden;
}
