.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.muted {
    color: var(--muted);
    font-size: small;
    margin-top: -10px;
}

.tabs {
    display: inline-flex;
    gap: 6px;
    padding: 5px;
    height: 50px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .03);
}

.tab-btn,
.btn {
    border: 1px solid var(--line);
    background: var(--panel2);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
}

.tab-btn {
    border-radius: 999px;
    background: transparent;
}

.tab-btn.active,
.btn-primary {
    background: var(--brand);
    border-color: transparent;
    color: #fff;
}

.shell {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 18px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-head {
    display: flex;
    justify-content: space-between;
}

.panel-head,
.panel-body {
    padding: 18px;
}

.panel-head {
    padding-bottom: 0;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    color: #dce8e1;
}

input[type="file"],
input[type="number"],
input[type="range"] {
    width: 100%;
}

input[type="number"],
select {
    width: 100%;
    background: rgba(255, 255, 255, .04);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.logo-box {
    min-height: 120px;
    display: grid;
    place-items: center;
    border: 1px dashed rgba(255, 255, 255, .15);
    border-radius: 14px;
    background: rgba(255, 255, 255, .02);
    overflow: hidden;
    margin-bottom: 12px;
    padding: 14px;
}

.logo-box img {
    max-width: 100%;
    max-height: 90px;
    object-fit: contain;
    display: block;
}

#logo-container{
    align-self: flex-start;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.card {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}

.thumb {
    aspect-ratio: 4/5;
    background: #0a0f0c;
    position: relative;
}

.thumb img,
.thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .55);
    font-size: 12px;
}

.card-body {
    padding: 14px;
    display: grid;
    gap: 10px;
}

.editor.hidden,
.library.hidden,
.hidden {
    display: none !important;
}

.editor-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 18px 18px 0;
}

.editor-content {
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
}

#editorDesc{
    margin-top: 2px;
}

#subtitle{
    margin-top: 1px;
}

#logo-subtitle{
    margin-top: 10px;
}

.stage-shell {
    min-height: 500px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .02);
    padding: 18px;
}

.stage {
    width: 100%;
    max-width: 720px;
    aspect-ratio: 1080 / 1350;
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: #0b0f0d;
}

.base-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.safe-area {
    position: absolute;
    border: 2px dashed rgba(255, 255, 255, .55);
    background: rgba(255, 255, 255, .05);
    pointer-events: none;
    border-radius: 10px;
}

.safe-label {
    position: absolute;
    top: -28px;
    left: 0;
    font-size: 11px;
    background: rgba(0, 0, 0, .6);
    border: 1px solid rgba(255, 255, 255, .12);
    padding: 5px 8px;
    border-radius: 999px;
}

.logo-layer {
    position: absolute;
    display: none;
    cursor: grab;
}

.logo-layer.active {
    display: block;
}

.logo-layer img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.controls {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: rgba(255, 255, 255, .02);
}

.mini-actions,
.pill-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill-btn {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .03);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.pill-btn.active {
    background: var(--brand);
    border-color: transparent;
}

.status {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    margin-top: 10px;
}
input[type="text"] {
    width: 100%;
    background: rgba(255, 255, 255, .04);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.price-layer {
    position: absolute;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    line-height: 1;
    cursor: grab;
    user-select: none;
    touch-action: none;
    z-index: 3;
}

.price-layer:active { cursor: grabbing; }
.price-area { border-color: rgba(255, 220, 90, .85); background: rgba(255, 220, 90, .06); }
code { font-family: Consolas, monospace; }

/* O preço precisa permanecer acima da arte-base e visível desde o primeiro frame. */
.price-layer {
    display: block;
    min-width: max-content;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}


/* Editor de ofertas: usa toda a largura quando o painel de logo não é necessário. */
.shell.price-editor-mode {
    grid-template-columns: minmax(0, 1fr);
}

.shell.price-editor-mode > #logo-container {
    display: none !important;
}

.price-editor .editor-content {
    grid-template-columns: minmax(320px, 1fr) minmax(260px, 320px);
}

.price-editor .stage-shell {
    min-height: 620px;
}

.price-editor .stage {
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.price-template-placeholder {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    place-items: center;
    padding: 32px;
    text-align: center;
    background:
        linear-gradient(135deg, rgba(255,255,255,.035) 25%, transparent 25%) 0 0 / 28px 28px,
        linear-gradient(315deg, rgba(255,255,255,.035) 25%, transparent 25%) 0 0 / 28px 28px,
        #111814;
}

.price-template-placeholder__content {
    display: grid;
    gap: 14px;
    max-width: 360px;
    padding: 26px;
    border: 1px dashed rgba(255,255,255,.25);
    border-radius: 18px;
    background: rgba(0,0,0,.24);
}

.price-template-placeholder__content span,
.price-template-placeholder__content small {
    color: var(--muted);
}

.price-template-placeholder__content strong {
    line-height: 1.45;
}

.base-media.media-error {
    display: none;
}

.price-area {
    z-index: 2;
}

.price-layer {
    z-index: 4;
}

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

    .price-editor .stage-shell {
        min-height: 0;
    }
}

.media-fallback {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background: #f3f4f6;
  color: #374151;
}

.media-fallback span {
  font-size: 0.85rem;
  color: #6b7280;
}


/* =========================================================
   MODO DE EDIÇÃO EM UMA TELA
   Mantém preview e controles visíveis dentro de 100dvh.
   ========================================================= */
body.editor-active {
    overflow: hidden;
}

body.editor-active .app {
    height: 100dvh;
    max-width: 1600px;
    padding: 12px;
}

body.editor-active .shell {
    height: calc(100dvh - 24px);
    min-height: 0;
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
    gap: 12px;
}

body.editor-active .shell.price-editor-mode {
    grid-template-columns: minmax(0, 1fr);
}

body.editor-active .panel {
    min-height: 0;
}

body.editor-active #logo-container {
    max-height: 100%;
    overflow-y: auto;
}

body.editor-active #editorView {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.editor-active #editorView.hidden {
    display: none !important;
}

body.editor-active .editor-top {
    flex: 0 0 auto;
    padding: 12px 14px 0;
}

body.editor-active .editor-content,
body.editor-active .price-editor .editor-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 14px 14px;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
}

body.editor-active .stage-shell,
body.editor-active .price-editor .stage-shell {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 10px;
}

body.editor-active .stage {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

body.editor-active .controls {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

body.editor-active .field {
    margin-bottom: 10px;
}

body.editor-active .controls .btn,
body.editor-active .controls .pill-btn {
    padding-top: 8px;
    padding-bottom: 8px;
}

@media (max-width: 1100px) {
    body.editor-active {
        overflow: auto;
    }

    body.editor-active .app,
    body.editor-active .shell {
        height: auto;
        min-height: 100dvh;
    }

    body.editor-active .shell,
    body.editor-active .shell.price-editor-mode {
        grid-template-columns: 1fr;
    }

    body.editor-active #logo-container {
        max-height: none;
        overflow: visible;
    }

    body.editor-active #editorView {
        height: auto;
    }

    body.editor-active .editor-content,
    body.editor-active .price-editor .editor-content {
        grid-template-columns: 1fr;
    }

    body.editor-active .stage-shell,
    body.editor-active .price-editor .stage-shell {
        height: min(70dvh, 720px);
    }

    body.editor-active .controls {
        height: auto;
        overflow: visible;
    }
}


/* Nas ofertas, o logo da revenda fica editável junto com o preço. */
.price-editor .logo-layer {
    z-index: 5;
}
