:root {
    --primary: #4f46e5;       /* Indigo */
    --primary-dark: #3730a3;
    --accent: #06b6d4;        /* Cyan */
    --bg-body: #f3f4f6;       
    --surface: #ffffff;
    --text-main: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.background-decor {
    position: fixed; top: 0; left: 0; width: 100%; height: 300px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    z-index: -1; clip-path: polygon(0 0, 100% 0, 100% 70%, 0 100%);
}

.app-wrapper {
    width: 100%; max-width: 1600px; 
    display: flex; flex-direction: column; gap: 20px;
}

/* Header */
header { text-align: center; color: white; margin-bottom: 10px; }
.logo-area { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 5px; }
.logo-icon { font-size: 2rem; opacity: 0.9; }
h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -1px; text-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.subtitle { font-size: 1rem; font-weight: 300; opacity: 0.9; }

/* Layout */
.main-grid {
    display: grid;
    grid-template-columns: 340px 1fr; 
    gap: 25px;
    height: calc(100vh - 140px); 
}
@media (max-width: 900px) { 
    .main-grid { grid-template-columns: 1fr; height: auto; } 
    .config-panel { max-height: 500px; }
}

/* --- PANEL IZQUIERDO (CONFIG) --- */
.panel {
    background: var(--surface); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,0.5);
}

.config-panel {
    overflow-y: auto; 
    padding-right: 15px; 
}

/* Scrollbar bonita */
.config-panel::-webkit-scrollbar { width: 6px; }
.config-panel::-webkit-scrollbar-track { background: #f1f1f1; }
.config-panel::-webkit-scrollbar-thumb { background: #c7c7c7; border-radius: 3px; }
.config-panel::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

.panel-header h2 {
    font-size: 0.9rem; color: var(--primary); margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.separator { border: 0; border-top: 1px solid var(--border); margin: 15px 0; }

/* Inputs y Grids */
.input-group { margin-bottom: 10px; }
.row-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.row-3-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }

label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-light); margin-bottom: 4px; }
.sub-label { font-size: 0.75rem; font-weight: 700; color: var(--text-main); margin-bottom: 6px; display: block; }

input[type="number"], input[type="text"], select {
    width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
    font-family: inherit; font-size: 0.85rem; background-color: #f9fafb;
}
input:focus, select:focus { outline: none; border-color: var(--primary); background: white; }

/* Input Archivo */
.file-input { font-size: 0.75rem; padding: 4px; }
input[type="file"]::file-selector-button {
    margin-right: 8px; border: none; background: var(--primary); padding: 4px 8px; border-radius: 4px;
    color: #fff; cursor: pointer; font-size: 0.75rem;
}

/* Input Color */
.color-input { width: 100%; height: 32px; padding: 2px; cursor: pointer; border-radius: 6px; border: 1px solid var(--border); }

/* Select */
.select-wrapper { position: relative; }
.select-wrapper i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-light); font-size: 0.7rem; }
select { appearance: none; cursor: pointer; }

/* RANGOS PERSONALIZADOS */
.range-group { 
    background: #f8fafc; 
    padding: 8px; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    margin-bottom: 10px; 
}

/* FIX ALINEACIÓN VDG Puntos: Usamos Flexbox con anchos fijos para la columna central */
.range-row { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 8px; 
}

/* 1. Símbolo (<, >) */
.range-row span:first-child {
    width: 20px; 
    text-align: center;
    font-weight: bold;
    color: var(--text-main);
}

/* 2. Valor Numérico: Aplicar ancho fijo */
.range-row input[type="number"] {
    width: 80px !important; 
    text-align: center;
}

/* 3. Etiqueta "Resto" (La clave de alineación, debe coincidir visualmente con el input) */
.range-row .range-static {
    width: 80px;  /* Ancho fijo idéntico al input */
    display: flex; /* Usar flex para centrar contenido */
    justify-content: center;
    align-items: center; /* Centrado vertical */
    background-color: var(--bg-body); 
    color: var(--text-light);
    font-size: 0.85rem; 
    
    /* Propiedades para igualar el modelo de caja del input[type="number"] */
    min-height: 32px; /* Asegura la altura. Los inputs estándar tienen ~32px */
    padding: 0 8px; 
    border: 1px solid var(--border); /* Borde idéntico al input */
    border-radius: 6px;
    box-sizing: border-box; 
    font-style: italic;
    line-height: normal; /* Asegura que no interfiera */
}

/* 4. Selectores de Color */
.range-row input[type="color"] {
    width: 40px;
    height: 32px; 
    padding: 0;
    border: 1px solid var(--border); 
    border-radius: 6px; 
    cursor: pointer;
    flex-shrink: 0; 
}


/* --- COLUMNA DERECHA --- */
.right-column { display: flex; flex-direction: column; gap: 15px; overflow: hidden; }

/* Barra rápida de texto */
.quick-config-bar {
    display: flex; gap: 15px; background: white; padding: 10px 15px; border-radius: var(--radius); box-shadow: var(--shadow); align-items: center;
}
.flex-grow { flex-grow: 1; }
.narrow { width: 50px; }
.quick-config-bar .input-group { margin-bottom: 0; }

/* Canvas */
.canvas-panel {
    flex-grow: 1; display: flex; align-items: center; justify-content: center;
    background: #e5e7eb; 
    padding: 20px; position: relative; overflow: hidden;
}
.canvas-wrapper {
    width: 100%; height: 100%; overflow: auto;
    display: flex; justify-content: center; align-items: center;
}
#mapCanvas {
    background: white; box-shadow: 0 0 20px rgba(0,0,0,0.15); max-width: 100%; max-height: 100%;
}
.empty-message {
    position: absolute; text-align: center; color: var(--text-light); pointer-events: none;
}
.empty-message i { font-size: 3rem; margin-bottom: 10px; opacity: 0.5; }

/* Botones Exportar */
.actions-container { display: flex; gap: 15px; justify-content: flex-end; }
.btn-secondary {
    background: white; border: 1px solid var(--border); color: var(--text-main); padding: 10px 16px; border-radius: 8px;
    font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px;
}
.btn-secondary:hover { background: var(--bg-body); border-color: var(--primary); color: var(--primary); }

footer { text-align: center; color: var(--text-light); font-size: 0.8rem; margin-top: 10px; }