:root {
  --orange: #ff7a00;
  --orange-dark: #e56700;
  --blue: #1f3b82;
  --blue-dark: #10245a;
  --banner-blue: #0cacdf;

  --bg: #f6f8fc;
  --text: #0f172a;
  --muted: #53698f;
  --border: #dfe7f2;
  --card: #ffffff;
  --shadow: 0 8px 22px rgba(15, 23, 42, 0.07);

  --preview-bg-dark: #151821;
  --preview-surface: #343842;
  --preview-text: #f2f4f8;
  --preview-muted: #c9cfda;
  --preview-danger: #f1b9b9;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  font-size: 13px;
}

/* HEADER */

.app-header {
  height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid #e6edf7;
  background: rgba(246, 248, 252, 0.96);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.brand img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.new-agent-btn {
  border: none;
  background: #ffffff;
  color: #111827;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  cursor: pointer;
}

/* LAYOUT */

.page {
  display: grid;
  grid-template-columns: minmax(0, 720px) 265px;
  gap: 20px;
  padding: 22px 22px 40px;
  max-width: 1060px;
  margin: 0 auto;
}

.form-area {
  min-width: 0;
}

.hero {
  margin-bottom: 18px;
}

.hero h1 {
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.055em;
  margin-bottom: 7px;
}

.hero p {
  max-width: 620px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

/* CARDS */

.section-card {
  background: var(--card);
  border: 1px solid #e1e8f2;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 15px;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title span {
  width: 29px;
  height: 29px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 13px;
  flex-shrink: 0;
}

.section-title h2 {
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.section-title p {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 3px;
}

/* SUBSEÇÕES */

.form-subsection {
  margin-top: 12px;
}

.form-subsection h3 {
  font-size: 13.5px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 4px;
}

.form-subsection p {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.soft-divider {
  border: none;
  border-top: 1px solid #edf1f7;
  margin: 18px 0;
}

/* OPTIONS */

.option-grid {
  display: grid;
  gap: 10px;
}

.option-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.option-card {
  min-height: 56px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  cursor: pointer;
  transition: 0.2s ease;
}

.option-card input {
  display: none;
}

.option-card i {
  width: 18px;
  height: 18px;
  border: 2px solid var(--blue);
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.option-card strong {
  display: block;
  font-size: 12.5px;
  line-height: 1.2;
}

.option-card small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  margin-top: 2px;
}

.option-card:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.option-card:has(input:checked) {
  border-color: var(--blue);
  background: rgba(31, 59, 130, 0.04);
}

.option-card:has(input:checked) i {
  background: var(--blue);
  border-color: var(--blue);
}

.option-card:has(input:checked) i::after {
  content: "✓";
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

/* FIELDS */

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 800;
  margin-bottom: 5px;
}

.field input,
.field textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 9px;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: 0.2s ease;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.025);
}

.field textarea {
  min-height: 68px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #8b9ab2;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 59, 130, 0.08);
}

.field input.invalid,
.field textarea.invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.field input.valid,
.field textarea.valid {
  border-color: #183275;
}

.field-row {
  display: grid;
  gap: 12px;
}

.field-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* UPLOAD */

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.upload-box {
  min-height: 78px;
  border: 1.7px dashed #dce5f1;
  background: #f9fbff;
  border-radius: 12px;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: 0.2s ease;
  padding: 10px;
}

.upload-box.small {
  min-height: 82px;
}

.upload-box input {
  display: none;
}

.upload-box span {
  font-size: 18px;
}

.upload-box strong {
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  word-break: break-word;
}

.upload-box small {
  display: block;
  font-size: 10px;
  margin-top: 3px;
}

.upload-box:hover {
  border-color: var(--blue);
  background: rgba(31, 59, 130, 0.03);
}

.upload-preview-card {
  display: none;
  margin-top: 8px;
  border: 1px solid #e3eaf4;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.upload-preview-card.show {
  display: block;
}

.upload-preview-card img {
  width: 100%;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  max-height: 140px;
}

/* ACTIONS */

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 10px;
}

.draft-btn,
.submit-btn {
  border: none;
  padding: 9px 15px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.draft-btn {
  background: #fff;
  color: #0f172a;
  box-shadow: var(--shadow);
}

.submit-btn {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 10px 22px rgba(255, 122, 0, 0.22);
}

.submit-btn:hover {
  background: var(--orange-dark);
}

.submit-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

/* MESSAGE BOX */

#messageBox {
  display: none;
  padding: 12px;
  border-radius: 10px;
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

#messageBox.success {
  display: block;
  background: #ecfdf3;
  color: #027a48;
  border: 1px solid #abefc6;
}

#messageBox.error {
  display: block;
  background: #fef3f2;
  color: #b42318;
  border: 1px solid #fecdca;
}

/* PREVIEW AREA */

.preview-area {
  position: sticky;
  top: 70px;
  width: 265px;
  height: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 16px;
}

.preview-tabs {
  display: flex;
  gap: 6px;
  background: #fff;
  padding: 4px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  margin-bottom: 9px;
}

.preview-tabs button {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
}

.preview-tabs button.active {
  background: var(--orange);
  color: #fff;
}

.phone-preview {
  display: none;
}

.phone-preview.active {
  display: block;
}

.phone-frame {
  width: 240px;
  height: min(465px, calc(100vh - 145px));
  border: 8px solid #0a1023;
  border-radius: 30px;
  overflow: hidden;
  background: var(--preview-bg-dark);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.18);
}

.preview-dark {
  color: var(--preview-text);
}

.device-status {
  height: 27px;
  padding: 0 11px;
  background: #171a23;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 8.5px;
  font-weight: 800;
}

.chat-topbar,
.profile-topbar {
  height: 42px;
  padding: 0 10px;
  background: #191c25;
  display: flex;
  align-items: center;
}

.chat-topbar {
  justify-content: space-between;
}

.profile-topbar {
  justify-content: flex-start;
}

.topbar-icon {
  font-size: 15px;
  line-height: 1;
}

.chat-topbar-agent {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: -12px;
}

.chat-topbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

/* AVATAR */

.mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  overflow: hidden;
  font-size: 11px;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-agent-text strong {
  display: block;
  font-size: 11px;
  font-weight: 700;
}

/* PHONE SCROLL */

.phone-scroll {
  height: calc(100% - 69px);
  overflow-y: auto;
  padding: 9px;
  background: #161922;
}

.phone-scroll::-webkit-scrollbar {
  width: 4px;
}

.phone-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

.preview-empty-state {
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.04);
  color: #cad3df;
  border-radius: 14px;
  padding: 12px;
  font-size: 10.5px;
  line-height: 1.45;
}

.is-hidden {
  display: none !important;
}

/* PLACEHOLDER DIMENSÕES */

.preview-dimension-placeholder {
  width: 100%;
  height: 100%;
  background: var(--banner-blue);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.preview-dimension-placeholder strong {
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  position: relative;
  z-index: 2;
}

.preview-dimension-placeholder small {
  font-size: 9px;
  font-weight: 800;
  opacity: 0.95;
  line-height: 1;
  position: relative;
  z-index: 2;
}

/* Montanhas/ondas decorativas do banner */
.preview-dimension-placeholder::before,
.preview-dimension-placeholder::after {
  content: "";
  position: absolute;
  bottom: 0;
  z-index: 1;
  opacity: 0.24;
}

.preview-dimension-placeholder::before {
  left: 0;
  width: 62%;
  height: 48%;
  background: #087fa4;
  clip-path: polygon(
    0% 100%,
    0% 58%,
    12% 36%,
    24% 54%,
    36% 31%,
    50% 56%,
    64% 39%,
    80% 70%,
    80% 100%
  );
}

.preview-dimension-placeholder::after {
  right: 0;
  width: 50%;
  height: 48%;
  background: #087fa4;
  clip-path: polygon(
    0% 100%,
    0% 64%,
    18% 43%,
    34% 58%,
    52% 26%,
    70% 49%,
    86% 32%,
    100% 58%,
    100% 100%
  );
}

.logo-dimension-placeholder {
  width: 100%;
  height: 100%;
  background: #ffffff;
  color: #7d879c;
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
  overflow: hidden;
}

.logo-dimension-placeholder strong {
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.logo-dimension-placeholder small {
  font-size: 6px;
  font-weight: 800;
  opacity: 0.95;
  line-height: 1;
}

/* Ajuste específico no mini avatar */
.mini-avatar .logo-dimension-placeholder strong {
  font-size: 6px;
}

.mini-avatar .logo-dimension-placeholder small {
  font-size: 4.8px;
}

/* Ajuste específico na logo maior do perfil */
.profile-hero-logo .logo-dimension-placeholder strong {
  font-size: 9px;
}

.profile-hero-logo .logo-dimension-placeholder small {
  font-size: 7px;
}

/* CHAT */

.chat-topbar {
  justify-content: flex-start;
  gap: 8px;
}

.chat-topbar-agent {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 0;
  min-width: 0;
  flex: 1;
}

.chat-topbar-agent .mini-avatar {
  flex-shrink: 0;
}

.mini-agent-text {
  min-width: 0;
  flex: 1;
}

.mini-agent-text strong {
  display: block;
  font-size: 11px;
  font-weight: 700;
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-topbar-right {
  margin-left: auto;
  flex-shrink: 0;
}

.official-agent-card {
  background: #0f121b;
  border-radius: 0;
  padding: 0 0 15px;
  text-align: center;
  margin-top: 2px;
  margin-left: -9px;
  margin-right: -9px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.official-chat-banner {
  width: calc(100% + 18px);
  height: 86px;
  background: var(--banner-blue);
  overflow: hidden;
  position: relative;
  display: block;
  margin-left: -9px;
  margin-right: -9px;
}

.official-chat-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.official-avatar {
  width: 60px;
  height: 60px;
  margin: -30px auto 10px;
  border-radius: 999px;
  background: #ffffff;
  border: 0;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  color: #7d879c;
  overflow: hidden;
  position: relative;
  z-index: 3;
}

.official-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.official-agent-card h3 {
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  margin: 0 12px 6px;
  line-height: 1.2;
  word-break: break-word;
}

.official-agent-card p {
  color: #d9dee8;
  font-size: 10.7px;
  line-height: 1.4;
  padding: 0 14px;
}

.message-date {
  text-align: center;
  color: #b6bfcd;
  font-size: 9.5px;
  padding: 9px 0 8px;
}

.chat-rich-message {
  background: #1e212a;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
}

.chat-rich-image {
  height: 105px;
  background: #ff7a00;
  overflow: hidden;
}

.chat-rich-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-rich-content {
  padding: 10px;
}

.chat-rich-content strong {
  display: block;
  font-size: 11.5px;
  margin-bottom: 4px;
}

.chat-rich-content p {
  color: #d3d8e2;
  font-size: 10.5px;
  line-height: 1.4;
}

.chat-action-row {
  padding: 0 10px 10px;
}

.chat-action-row button {
  border: 1px solid #d9e2ef;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 700;
  cursor: default;
}

.chat-composer {
  margin-top: 10px;
  background: #dce2ea;
  border-radius: 999px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #4b5563;
}

.composer-plus {
  width: 23px;
  height: 23px;
  border-radius: 999px;
  background: transparent;
  display: grid;
  place-items: center;
  font-weight: 900;
  flex-shrink: 0;
  font-size: 14px;
  color: #111827;
}

.composer-brand {
  flex: 1;
  color: #6b7280;
  font-size: 9.5px;
}

.composer-icons {
  display: flex;
  gap: 6px;
  font-size: 10px;
  color: #111827;
}

/* PROFILE */

.profile-hero {
  text-align: center;
}

.profile-hero-banner {
  height: 118px;
  background: var(--banner-blue);
  overflow: hidden;
  position: relative;
  margin: -9px -9px 0 -9px;
  border-radius: 0;
}

.profile-hero-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-hero-logo {
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background: #ffffff;
  border: 0;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  margin: -31px auto 0;
  display: grid;
  place-items: center;
  color: #7d879c;
  font-size: 22px;
  font-weight: 900;
  overflow: hidden;
  position: relative;
  z-index: 3;
}

.profile-hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-hero h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 9px 0 4px;
}

.profile-hero p {
  color: #d7dde8;
  font-size: 10.5px;
  line-height: 1.4;
  padding: 0 6px;
}

.profile-main-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.profile-action-pill {
  background: #47516b;
  border-radius: 999px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #fff;
}

.profile-action-pill .icon {
  font-size: 14px;
  line-height: 1;
}

.profile-action-pill .label {
  font-size: 9px;
  font-weight: 700;
}

.profile-block {
  background: var(--preview-surface);
  border-radius: 14px;
  padding: 10px;
  margin-top: 10px;
}

.profile-menu-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.profile-menu-item {
  min-height: 48px;
  border-radius: 12px;
  background: #3a3f4a;
  padding: 8px 9px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-menu-item .icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

.profile-menu-item .text strong {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
}

.profile-menu-item .text small {
  display: block;
  color: #d3dae7;
  font-size: 9px;
  margin-top: 2px;
}

.profile-menu-item.danger {
  color: var(--preview-danger);
}

/* CROP MODAL */

.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.crop-modal.show {
  display: flex;
}

.crop-modal-content {
  width: min(620px, 96vw);
  max-height: 92vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
}

.crop-modal-header {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crop-modal-header h3 {
  font-size: 14px;
}

.crop-modal-header button {
  border: none;
  background: transparent;
  font-size: 17px;
  cursor: pointer;
}

.crop-modal-body {
  padding: 12px;
  background: #f8fafc;
  height: min(430px, 64vh);
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-modal-body img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.crop-modal-actions {
  padding: 12px 14px;
  border-top: 1px solid #eef2f8;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.cropper-container {
  max-width: 100% !important;
}

.cropper-view-box,
.cropper-face {
  border-radius: 0;
}

/* RESPONSIVE */

@media (max-width: 1020px) {
  .page {
    grid-template-columns: 1fr;
    max-width: 760px;
  }

  .preview-area {
    position: static;
    width: 100%;
    margin-top: 18px;
  }

  .phone-frame {
    width: 240px;
    height: 465px;
  }
}

@media (max-width: 900px) {
  .app-header {
    padding: 0 16px;
  }

  .page {
    padding: 20px 16px 40px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .option-grid.two,
  .option-grid.three,
  .field-row.two,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .draft-btn,
  .submit-btn {
    width: 100%;
  }
}