@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Fredoka:wght@400;700&family=Indie+Flower&family=Montserrat:wght@400;800&display=swap');

body {
    margin: 0;
    padding: 0;
    background-color: #555;
    display: flex;
}

/* PANEL IZQUIERDO */
#panel-control {
    width: 420px;
    height: 100vh;
    background: #2c3e50;
    color: white;
    padding: 20px;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    box-sizing: border-box;
    z-index: 1000;
}

.formulario-columna {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formulario-columna input,
.formulario-columna select {
    padding: 10px;
    border-radius: 5px;
    border: none;
}

#drop-preview {
    height: 60px;
    border: 2px dashed #95a5a6;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    background-color: rgba(0, 0, 0, 0.2);
    position: relative;
}

.btn-mini-clear {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
    padding: 2px 5px;
}

.btn-add {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 5px;
    border-radius: 5px;
}

.btn-print {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    margin-top: 5px;
    border-radius: 5px;
}

.btn-clear {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    margin-top: 5px;
    border-radius: 5px;
}

/* AREA DE LA HOJA */
.area-impresion {
    flex-grow: 1;
    margin-left: 420px;
    display: flex;
    justify-content: center;
    padding: 20px;
    min-width: 800px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
}

#zoom-range {
    flex-grow: 1;
    cursor: pointer;
}

.hoja-a4 {
    width: 210mm;
    height: 297mm;
    background: white;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transform-origin: top center;
    transition: transform 0.2s ease-out;
}

/* MARCAS DE REGISTRO CAMEO (Tus medidas exactas) */
.marca { position: absolute; background: black; z-index: 5; }
.top-left { top: 15.88mm; left: 15.88mm; width: 5mm; height: 5mm; }
.top-right { top: 15.88mm; right: 15.88mm; width: 20mm; height: 20mm; background: none; border-top: 0.5mm solid black; border-right: 0.5mm solid black; }
.bottom-left { bottom: 15.88mm; left: 15.88mm; width: 20mm; height: 20mm; background: none; border-bottom: 0.5mm solid black; border-left: 0.5mm solid black; }

/* GRID Y ETIQUETAS (Refactorizado) */
.grid-etiquetas { 
    position: absolute; 
    left: 17mm; 
    top: 36.85mm; 
    display: grid; 
    grid-template-columns: 85mm 85mm; 
    grid-template-rows: repeat(5, 43mm); 
    column-gap: 5mm; 
    row-gap: 1.825mm; 
}

.etiqueta { 
    width: 85mm; 
    height: 43mm; 
    position: relative; 
    overflow: hidden; 
    border: 0.1mm solid rgba(255, 0, 0, 0.1); 
}

.fondo-sangrado { 
    position: absolute; 
    top: -1mm; 
    left: -1mm; 
    right: -1mm; 
    bottom: -1mm; 
    background-size: cover; 
    background-position: center; 
    z-index: 0; 
}

/* ALINEACIÓN IZQUIERDA (Icono derecha) */
.contenido-texto {
    position: absolute;
    top: 3mm;
    left: 3mm;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 1mm;
    align-items: flex-start;
}

.personaje {
    max-height: 35mm;
    position: absolute;
    bottom: 1mm;
    right: 1mm;
    z-index: 1;
}

/* ALINEACIÓN DERECHA (Icono izquierda) */
.etiqueta.derecha .contenido-texto {
    left: auto;
    right: 3mm;
    align-items: flex-end;
    text-align: right;
}

.etiqueta.derecha .personaje {
    right: auto;
    left: 1mm;
}

.etiqueta.derecha .txt-materia {
    border-left: none;
    border-right: 3px solid #ff4757;
    padding-left: 0;
    padding-right: 5px;
}

.caja-blanca {
    background: rgba(255, 255, 255, 1);
    padding: 1mm 3mm;
    border-radius: 1.5mm;
    width: fit-content;
    max-width: 50mm;
    word-wrap: break-word;
    line-height: 1.1;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.txt-nombre {
    font-size: 10pt;
    font-weight: bold;
    text-transform: uppercase;
}

.txt-grado {
    font-size: 10pt;
}

.txt-materia {
    font-size: 10pt;
    border-left: 3px solid #ff4757;
    padding-left: 5px;
}

.btn-borrar {
    position: absolute;
    top: 0;
    right: 0;
    background: red;
    color: white;
    border: none;
    cursor: pointer;
    z-index: 10;
    padding: 2px 6px;
}

@media print {
    .no-print {
        display: none !important;
    }

    #panel-control {
        display: none;
    }

    .area-impresion {
        margin: 0;
        padding: 0;
    }

    .hoja-a4 {
        transform: scale(1) !important;
        margin: 0;
        box-shadow: none;
    }

    body {
        background: white;
    }
}

/* Categorías Galería */
.cat-grupo {
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
    border-radius: 4px;
    overflow: hidden;
}

.cat-grupo summary {
    padding: 8px;
    background: #34495e;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    color: #3498db;
    list-style: none;
    border-bottom: 1px solid #2c3e50;
}

.cat-grupo summary::before {
    content: "📁 ";
}

.cat-grupo .items-v {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.thumb,
.thumb-icon {
    width: 100%;
    height: 45px;
    object-fit: cover;
    background: white;
    cursor: pointer;
    border-radius: 3px;
}

/* Selectores de Alineación Visual */
.align-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
}

.align-btn {
    flex: 1;
    padding: 10px;
    background: #34495e;
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 11px;
    transition: all 0.2s;
}

.align-btn.active {
    border-color: #27ae60;
    background: #1e2b38;
}

.align-btn span {
    font-size: 18px;
    margin-bottom: 3px;
}

/* Ajuste dinámico del Preview */
#drop-preview {
    transition: all 0.3s ease;
    flex-direction: row;
    /* Icono a la derecha por defecto */
}

#drop-preview.derecha {
    flex-direction: row-reverse;
    /* Mueve el icono a la izquierda visualmente */
}

/* Color dinámico en el panel de control para los labels */
.preview-text-color {
    font-weight: bold;
    transition: color 0.2s;
}

.marca-agua {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 60px;
    color: rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    font-weight: bold;
    text-transform: uppercase;
}

/* Marca de agua individual */
.watermark-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 14pt;
    color: rgba(0, 0, 0, 0.15);
    /* Muy tenue */
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
    font-weight: bold;
    text-transform: uppercase;
    display: block;
}

/* Clase especial para la descarga final */
.modo-impresion-final .watermark-inner, 
.modo-impresion-final .btn-borrar {
    display: none !important;
}

/* Ocultar marca de agua solo al generar el PDF final */
.no-watermark .watermark-inner {
    display: none !important;
}

#num-hojas {
    display: inline-block;
    transition: transform 0.2s ease;
}

.btn-clear:hover {
    background: #c0392b !important;
}