/* --- VARIABLES Y RESET --- */
:root {
    --bg-app: #121212;
    --bg-panel: #1e1e1e;
    --primary: #86bc25; /* Verde Durango */
    --primary-hover: #9cd634;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --border: #333333;
    
    /* Configuración del Lienzo REAL (Salida) */
    --canvas-size: 1280px; 
}

body {
    margin: 0;
    height: 100vh;
    font-family: 'Montserrat', sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    overflow: hidden; /* Evita scrolls dobles */
}

.app-layout {
    display: flex;
    height: 100%;
    width: 100%;
}

/* --- SIDEBAR (IZQUIERDA) --- */
.sidebar {
    width: 380px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 5px 0 15px rgba(0,0,0,0.3);
}

.sidebar header {
    padding: 20px;
    background: #181818;
    border-bottom: 1px solid var(--border);
}

.sidebar header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Paneles de Control */
.panel {
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.panel h3 {
    margin-top: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

/* Inputs y Controles */
textarea {
    width: 100%;
    height: 80px;
    background: #151515;
    border: 1px solid #444;
    color: white;
    padding: 10px;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    box-sizing: border-box; 
}
textarea:focus { outline: 1px solid var(--primary); }

input[type="text"] {
    width: 100%;
    background: #151515;
    border: 1px solid #444;
    color: white;
    padding: 8px;
    box-sizing: border-box;
}

/* Botón Upload Bonito */
.custom-file-upload {
    display: block;
    background: #333;
    color: #eee;
    padding: 12px;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    border: 1px dashed #666;
    transition: 0.2s;
}
.custom-file-upload:hover {
    background: #3a3a3a;
    border-color: var(--primary);
    color: var(--primary);
}
input[type="file"] { display: none; }

/* Sliders */
input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    margin: 10px 0;
}

/* Switches */
.switch-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    font-size: 0.85rem;
    color: #ccc;
}
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #444;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Área de Acción (Botón Descargar) */
.action-area {
    padding: 20px;
    background: #181818;
    border-top: 1px solid var(--border);
}
.btn-descargar {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 6px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.1s;
}
.btn-descargar:hover { background: var(--primary-hover); transform: scale(1.02); }
.btn-descargar:active { transform: scale(0.98); }
.btn-descargar:disabled { background: #555; cursor: wait; }

/* Input logo con botón */
.input-with-icon { display: flex; gap: 5px; }
.input-with-icon button {
    background: #333; border: 1px solid #444; color: white; width: 40px; cursor: pointer;
}

/* --- STAGE (ZONA DE PREVISUALIZACIÓN) --- */
.preview-stage {
    flex: 1;
    background-color: #050505;
    background-image: linear-gradient(45deg, #0f0f0f 25%, transparent 25%, transparent 75%, #0f0f0f 75%, #0f0f0f), 
                      linear-gradient(45deg, #0f0f0f 25%, transparent 25%, transparent 75%, #0f0f0f 75%, #0f0f0f);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

/* Scaler: Hace que el lienzo gigante quepa en la pantalla */
.canvas-scaler {
    transform: scale(0.45); 
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border: 2px solid #333;
}

.preview-info {
    margin-top: 10px;
    color: #666;
    font-size: 0.8rem;
    font-family: monospace;
}

/* --- EL LIENZO REAL (LO QUE SE EXPORTA) --- */
#lienzo-final {
    width: var(--canvas-size);  /* 1280px */
    height: var(--canvas-size); /* 1280px */
    background: #000;
    position: relative;
    overflow: hidden;
}

/* --- SOLUCIÓN FONDO APLASTADO (VERSIÓN DIV) --- */
#img-fondo {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    z-index: 1;
    
    /* ESTA ES LA CLAVE: El fondo se recorta automáticamente */
    background-size: cover; 
    background-position: center 20%;
    background-repeat: no-repeat;
    
    /* Placeholder mientras cargas algo */
    background-color: #222; 
}

.con-filtro {
    filter: contrast(1.1) saturate(1.1) brightness(0.9);
}

/* Capa Gradiente (BASE) */
.capa-gradiente {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, 
        rgba(0,0,0,1) 0%, 
        rgba(0,0,0,0.8) 25%, 
        rgba(0,0,0,0) 60%);
    z-index: 5;
    pointer-events: none;
}

/* Logo (BASE) */
#img-logo {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    z-index: 10;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.8));
    
    /* FIX CRÍTICO: Mantiene la proporción para que no se estire */
    object-fit: contain; 
    height: auto; 
}

/* Texto (BASE) */
.zona-texto {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    padding: 50px 70px; /* Ajuste de márgenes para que respire */
    box-sizing: border-box;
    z-index: 20;
    text-align: center;
    border-bottom: 20px solid var(--primary); 
    
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 50%; 
}

/* --- SOLUCIÓN TEXTO MAYÚSCULAS/BLOQUE (BASE) --- */
#texto-render {
    font-family: 'Montserrat', sans-serif;
    color: white;
    margin: 0;
    
    /* 1. SEPARACIÓN DE LÍNEAS (Evita empalme) */
    line-height: 1.3;
    
    /* 2. GROSOR DE LETRA (Más limpio) */
    font-weight: 800;
    
    /* 3. QUITAR MAYÚSCULAS FORZADAS */
    text-transform: none; 
    
    text-shadow: 0 2px 10px rgba(0,0,0,0.9);
    
    /* FIX: Asegura que el texto ocupe el ancho correcto y baje de línea */
    width: 100%;
    word-wrap: break-word;
}

/* Resaltado Verde (BASE) */
.resaltado {
    color: var(--primary);
    display: block; 
    margin-bottom: 15px; 
    line-height: 1.1;
}

/* =========================================
   SISTEMA DE PLANTILLAS
   ========================================= */

/* --- PLANTILLA 2: ESTILO DARK LATERAL (.estilo-lateral) --- */

/* 1. El Logo se mueve a la derecha */
.estilo-lateral #img-logo {
    left: auto !important; /* Soltamos el centro */
    right: 50px !important; /* Pegamos a la derecha */
    top: 50px !important;
    transform: none !important; /* Quitamos el centrado matemático */
    width: 200px !important; /* Un poco más discreto */
}

/* 2. El Texto se alinea a la izquierda y tiene fondo sólido */
.estilo-lateral .zona-texto {
    align-items: flex-start !important; /* Alinear a la izquierda */
    text-align: left !important;
    padding: 60px 50px !important;
    
    /* Fondo negro sólido abajo en degradado fuerte */
    background: linear-gradient(to top, 
        rgba(0,0,0,1) 0%, 
        rgba(0,0,0,0.95) 40%, 
        rgba(0,0,0,0) 100%) !important;
    
    border-bottom: none !important; /* Quitamos la línea verde de abajo */
    border-left: 20px solid var(--primary); /* Ponemos la línea verde a la izquierda */
}

/* 3. Ajustes al texto para que se vea bien a la izquierda */
.estilo-lateral #texto-render {
    text-shadow: 2px 2px 0px #000;
    line-height: 1.2 !important;
}

/* 4. Resaltado tipo "Marcador" */
.estilo-lateral .resaltado {
    background-color: var(--primary);
    color: black;
    padding: 0 10px;
    display: inline-block; /* Caja estilo "resaltador" */
    margin-bottom: 10px;
    text-shadow: none;
}