/**
 * Layout incorporado ao tema — EXCLUSIVO do modo theme_embed.
 * Todas as regras ficam sob .dc-coloring-wrap.colorir-theme-embed para não colidir
 * com o fullscreen nem com outras partes do site.
 */

.dc-coloring-wrap.colorir-theme-embed {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 1rem 0 2rem;
    box-sizing: border-box;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/*
 * Referência: linha ~888×824, coluna canvas ~564×824, canvas interno ~409×800.
 * stretch: coluna do canvas acompanha a ALTURA da toolbar (evita área ~552px vs toolbar ~866px).
 */
.dc-coloring-wrap.colorir-theme-embed .dc-coloring-layout {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    min-height: 0;
}

/*
 * Coluna do canvas (sem wrapper interno): canvas + loading + zoom.
 * position: relative — ancoragem dos absolutes; overflow:hidden — zoom recortado aqui.
 */
.dc-coloring-wrap.colorir-theme-embed .dc-coloring-canvas-area {
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
    min-height: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
}

/*
 * Largura máx. do desenho ~564px (referência), centrada na coluna.
 */
.dc-coloring-wrap.colorir-theme-embed .dc-coloring-canvas-area #colorirCanvas {
    display: block;
    width: auto;
    height: auto;
    max-width: min(100%, 564px);
    max-height: min(82vh, 820px);
    margin: 0 auto;
    flex-shrink: 0;
    border-radius: 4px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
    vertical-align: top;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-zoom-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 4;
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 4px;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-loading.active {
    display: flex;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-toolbar {
    flex: 0 0 300px;
    flex-shrink: 0;
    width: 300px;
    max-width: 100%;
    box-sizing: border-box;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    align-self: stretch;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-label {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 0 8px;
    font-family: Montserrat, 'Open Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #6c757d;
    line-height: 1;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-label-inner {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-label-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    color: #39a8db;
    line-height: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-label-icon .dc-label-svg {
    width: 20px;
    height: 20px;
    display: block;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-label-icon .dc-label-svg--palette {
    width: 16px;
    height: 16px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-label-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 12px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-section:last-child,
.dc-coloring-wrap.colorir-theme-embed .dc-coloring-copyright {
    border-bottom: none;
    padding-bottom: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-tool-btn {
    flex: 1 1 85px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 64px;
    padding: 8px 6px 6px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #e8e8e8;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    color: #333;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.dc-coloring-wrap.colorir-theme-embed .dc-tool-btn .dc-btn-svg-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-tool-btn .dc-btn-svg {
    width: 20px;
    height: 20px;
    display: block;
}

.dc-coloring-wrap.colorir-theme-embed #btnBalde .dc-btn-svg {
    width: 24px;
    height: 24px;
}

.dc-coloring-wrap.colorir-theme-embed #btnPincel .dc-btn-svg {
    width: 18px;
    height: 18px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-tool-btn .dc-btn-svg-text {
    display: block;
    text-align: center;
}

.dc-coloring-wrap.colorir-theme-embed .dc-tool-btn:hover {
    background: #ddd;
}

.dc-coloring-wrap.colorir-theme-embed .dc-tool-btn.active {
    border-color: transparent;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-paletas.dc-coloring-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-btn-paleta {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 8px;
    font-size: 0.6875rem;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-cores.dc-coloring-swatches {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-cor-item {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    border-radius: 8px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-cor-item:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

.dc-coloring-wrap.colorir-theme-embed .colorir-cor-item.active {
    transform: none;
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.45);
}

.dc-coloring-wrap.colorir-theme-embed .dc-custom-color-btn.colorir-btn-adicionar {
    width: 100%;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid #39a8db;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    text-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    background: #ffffff !important;
    color: #39a8db !important;
}

.dc-coloring-wrap.colorir-theme-embed .dc-custom-color-btn.colorir-btn-adicionar:hover {
    transform: none !important;
    box-shadow: none !important;
    filter: none !important;
    background: #39a8db !important;
    color: #ffffff !important;
    border-color: #39a8db;
}

.dc-coloring-wrap.colorir-theme-embed .dc-custom-color-btn .dc-custom-color-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-custom-color-btn .dc-custom-color-btn-svg {
    width: 22px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-custom-color-btn .dc-custom-color-btn-text {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin: 0;
    padding: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-history {
    display: flex;
    gap: 8px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-history-btn {
    flex: 1;
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 0;
    padding: 10px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f3f3f3;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    color: #333;
}

.dc-coloring-wrap.colorir-theme-embed .dc-history-btn .dc-btn-svg-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-history-btn .dc-btn-svg {
    width: 22px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-btn-svg-wrap--mirror {
    transform: scaleX(-1);
}

.dc-coloring-wrap.colorir-theme-embed .dc-history-btn .dc-btn-svg-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin: 0;
    padding: 0;
    text-align: left;
    white-space: nowrap;
}

.dc-coloring-wrap.colorir-theme-embed .dc-history-btn:hover {
    background: #e8e8e8;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-act-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border: none;
    line-height: 1.2;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-btn-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-clear .dc-act-btn-icon svg {
    width: 18px;
    height: 18px;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-print {
    background: #39a8db;
    color: #fff;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-print:hover {
    background: #2b80a6;
    color: #fff;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-download {
    background: #fff;
    color: #39a8db;
    border: 2px solid #39a8db;
    box-shadow: none;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-download:hover {
    background: #fff;
    color: #39a8db;
    border-color: #39a8db;
    box-shadow: 0 0 0 1px rgba(57, 168, 219, 0.25);
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-share {
    background: #25d366;
    color: #fff;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-share:hover {
    background: #1da851;
    color: #fff;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-clear {
    background: #ff1c1c;
    color: #fff;
    border: 2px solid #ff1c1c;
}

.dc-coloring-wrap.colorir-theme-embed .dc-act-clear:hover {
    background: #fff;
    color: #ff1c1c;
    border-color: #ff1c1c;
}

.dc-coloring-wrap.colorir-theme-embed .dc-back-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    padding: 10px 12px;
    border-radius: 6px;
    background: #6c757d;
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1.25;
}

.dc-coloring-wrap.colorir-theme-embed .dc-back-link-icon {
    display: flex;
    flex: 0 0 20px;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.dc-coloring-wrap.colorir-theme-embed .dc-back-link-icon svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-back-link-text {
    flex: 1 1 auto;
    min-width: 0;
}

.dc-coloring-wrap.colorir-theme-embed .dc-back-link:hover {
    filter: brightness(1.05);
    color: #fff !important;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-copyright {
    margin-top: 8px;
    font-size: 0.6875rem;
    color: #777;
    text-align: center;
}

.dc-coloring-wrap.colorir-theme-embed .dc-coloring-copyright p {
    margin: 0;
}

.dc-coloring-wrap.colorir-theme-embed .colorir-tamanho-controle {
    margin-top: 10px;
}

/* Mobile / tablet estreito: coluna canvas + toolbar. Scroll só na barra de ferramentas (área do canvas inalterada). */
@media (max-width: 991px) {
    .dc-coloring-wrap.colorir-theme-embed .dc-coloring-layout {
        flex-direction: column;
        flex-wrap: wrap;
        align-items: stretch;
    }

    .dc-coloring-wrap.colorir-theme-embed .dc-coloring-toolbar {
        flex: 1 1 auto;
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* auto (padrão): no fim do scroll da toolbar, o gesto continua a rolar a página */
        max-height: min(52vh, 560px);
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .dc-coloring-wrap.colorir-theme-embed .dc-coloring-canvas-area {
        width: 100%;
        min-height: min(48vh, 420px);
        max-height: min(62vh, 560px);
    }

    .dc-coloring-wrap.colorir-theme-embed .dc-coloring-canvas-area #colorirCanvas {
        max-height: min(58vh, 520px);
    }
}
