/* Reset Básico e Estrutura Geral */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Verdana', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background-color: #f4f4f4;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: #333;
    color: #fff;
    padding: 1rem 0;
    text-align: center;
}

header h1 {
    margin-bottom: 0.5rem;
}

nav ul {
    list-style: none;
    padding: 0;
}

nav ul li {
    display: inline;
    margin: 0 10px;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
}

/* Layout Principal */
.container {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
    flex: 1; 
}
/* ==========================================================================
   VISUALIZAÇÃO NA TELA DO PC (Interface de Usuário)
   Como o quadro agora tem mais de 1100px de largura física, usamos transform: scale
   para ele caber na tela do computador sem estragar o tamanho real do PDF.
   ========================================================================== */
.canvas-container {
    width: 60%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #CCC;
    border-radius: 8px;
    padding: 40px 20px;
    overflow: hidden; /* Garante que o container segure o quadro escalado */
}

/* ==========================================================================
   MOLDURA EXTERNA (Corrigida e Absoluta)
   ========================================================================== */
#frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 14px solid #111;
    box-sizing: border-box;
    z-index: 10;
    pointer-events: none;
}
    /* ==========================================================================
   ARQUITETURA DE TAMANHO BASE DO CANVAS (Resolução Nativa de Impressão)
   ========================================================================== */
#canvas {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-sizing: border-box;
    margin: 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* ==========================================================================
   MODO RETRATO (A4 Vertical - Estável)
   ========================================================================== */
#canvas.modo-retrato {
    width: 794px;
    height: 1123px;
    aspect-ratio: 210 / 297 !important; /* Trava a proporção em pé */
    padding: 60px 50px;
}

#canvas.modo-retrato #iconSelected {
    width: 650px;
    height: 650px;
    margin-top: 0px;
    margin-bottom: 40px;
    z-index: 2;
}

#canvas.modo-retrato .nomeQuadro { font-size: 32px; top: 64%; }
#canvas.modo-retrato .text { font-size: 20px; top: 71%; }
#canvas.modo-retrato .barcode { width: 24%; top: 78%; }
#canvas.modo-retrato .barcodeQR { width: 12%; top: 79%; }
#canvas.modo-retrato #dateText { top: 87%; font-size: 18px; }
#canvas.modo-retrato #cityText { top: 90%; font-size: 16px; }
#canvas.modo-retrato #coordenadas { top: 93%; font-size: 15px; }

/* ==========================================================================
   MODO PAISAGEM (A4 Horizontal - Ajuste de Preenchimento)
   ========================================================================== */
#canvas.modo-paisagem {
    /* Mantemos a proporção de 10% reduzida que você aprovou, mas removemos travas rígidas */
    width: 761px !important;  
    height: 540px !important;  
    padding: 22px 36px !important;
    aspect-ratio: 297 / 210 !important; 
    box-sizing: border-box;
}

/* Mantém os elementos internos idênticos à sua última calibração */
#canvas.modo-paisagem #iconSelected {
    width: 376px !important;         
    height: 376px !important;        
    margin-top: -50px !important;     
    margin-bottom: 20px !important;
    z-index: 2;
}

#canvas.modo-paisagem .nomeQuadro { font-size: 20px !important; top: 58% !important; }
#canvas.modo-paisagem .text { font-size: 13px !important; top: 64% !important; }
#canvas.modo-paisagem .barcode { width: 15% !important; top: 71% !important; }
#canvas.modo-paisagem .barcodeQR { width: 7.5% !important; top: 72% !important; }
#canvas.modo-paisagem #dateText { font-size: 12px !important; top: 81% !important; }
#canvas.modo-paisagem #cityText { font-size: 11px !important; top: 86% !important; }
#canvas.modo-paisagem #coordenadas { font-size: 10px !important; top: 91% !important; }

/* Estilo flutuante idêntico ao de remover fundo */
.btn-remover-flutuante {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #dc3545; /* Vermelho padrão */
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
    transition: transform 0.1s ease;
}

.btn-remover-flutuante:hover {
    transform: scale(1.1);
    background: #c82333;
}

}/* ==========================================================================
   ELEMENTOS INTERNOS DO QUADRO (Ajustes de Fluxo e Posicionamento)
   ========================================================================== */
.decor-image {
    position: absolute;
    width: 80%;
    height: auto;
    top: 2%;
    left: 50%;
    transform: translateX(-50%);
}

.nomeQuadro, .text, .extra-text, #dateText, #cityText, #coordenadas {
    position: absolute;
    text-align: center;
    width: 100%;
    left: 0;
    padding: 0 20px;
    z-index: 3;
}

.nomeQuadro { font-size: 18px; font-weight: bold; top: 66%; letter-spacing: 1px; }
.text { font-size: 12px; top: 72%; font-style: italic; }

.barcode, .barcodeQR {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    z-index: 3;
}

.barcode { width: 22%; top: 79%; }
.barcodeQR { width: 10%; top: 80%; }

#dateText { top: 88%; font-size: 11px; }
#cityText { top: 91%; font-size: 10px; }
#coordenadas { top: 93.5%; font-size: 9px; font-weight: bold; font-style: normal; color: #aaa; }

/* Coluna de Controles */
.controls {
    width: 40%;
    padding: 25px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.controls h2 {
    margin-bottom: 20px;
    font-size: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.controls label {
    display: block;
    font-weight: bold;
    margin: 15px 0 5px 0;
    font-size: 14px;
}

.text-input, textarea {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    background: #fbfbfb;
}

textarea { resize: none; }

/* Opções Clicáveis */
.color-options, .icon-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.radio-color {
    appearance: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #ccc;
    transition: transform 0.1s ease;
}

.radio-color:checked {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #000;
}

.radio-color[value="black"] { background-color: black; }
.radio-color[value="darkslategray"] { background-color: darkslategray; }
.radio-color[value="DodgerBlue"] { background-color: DodgerBlue; }
.radio-color[value="indigo"] { background-color: indigo; }
.radio-color[value="magenta"] { background-color: magenta; }
.radio-color[value="darkmagenta"] { background-color: darkmagenta; }

.icon-option {
    width: 45px;
    height: 45px;
    cursor: pointer;
    border: 2px solid #eee;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: #000;
    padding: 4px;
}

.icon-option:hover { transform: scale(1.05); }

/* Controles Agrupados */
.inline-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.inline-controls > div { flex: 1; }

.barcode-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #eee;
}

.barcode-input-container > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

#qrcodeInputContainer, #spotifyInputContainer {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 25px;
    width: 100%;
}

/* Botão de Ação */
#btnImprimir {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 25px;
    background-color: #007bb5;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#btnImprimir:hover { background-color: #0056b3; }

footer {
    text-align: center;
    padding: 1rem 0;
    background: #333;
    color: #fff;
    width: 100%;
    margin-top: auto;
}

/* ==========================================================================
   REGRAS DE IMPRESSÃO - SANGRE TOTAL (Sem margens sobressalentes)
   ========================================================================== */
@media print {
    /* Configura a página física do PDF para remover qualquer margem padrão do navegador */
    @page {
        margin: 0 !important;
    }
    @page :left { margin: 0 !important; }
    @page :right { margin: 0 !important; }

    body *, header, footer, .controls { 
        display: none !important; 
    }
    
    body, .container, .canvas-container { 
        background: none !important; 
        padding: 0 !important; 
        margin: 0 !important; 
        width: 100% !important;
        height: 100% !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important; 
    }
    
    /* Força o Canvas a esticar e ocupar a folha inteira eliminando a sobra */
    #canvas { 
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important; 
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
/* Responsividade Mobile */
@media (max-width: 768px) {
    .container { flex-direction: column; }
    .canvas-container, .controls { width: 100%; }
    #canvas { width: 75%; }
    .inline-controls { flex-direction: column; gap: 5px; }
}
