* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f0f0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    touch-action: none;
}

.contenedor-aplicacion {
    background: white;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.barra-herramientas {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
    order: 2;
    min-height: 140px;
    flex-shrink: 0;
}

.grupo-herramientas {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 15px;
    border-radius: 12px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    height: 60px;
    min-height: 60px;
}

.btn-paleta {
    padding: 0;
    border: 3px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 28px;
    transition: all 0.2s;
    color: #333;
    touch-action: manipulation;
    height: 52px;
    width: 52px;
    min-height: 52px;
    min-width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-paleta:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-paleta.activo {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

/* Modal de paleta */
.modal-paleta {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.modal-paleta.oculto {
    display: none;
}

.modal-contenido {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalApertura 0.3s ease;
}

@keyframes modalApertura {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
    font-weight: 600;
}

.btn-cerrar-modal {
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #333;
    touch-action: manipulation;
}

.btn-cerrar-modal:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

.modal-body {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.grupo-modal {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.grupo-modal label {
    font-weight: 600;
    color: #333;
    font-size: 18px;
}

.grupo-colores {
    min-width: 300px;
}

.grupo-zoom {
    gap: 8px !important;
    padding: 4px 15px !important;
    height: 60px !important;
    min-height: 60px !important;
}

.colores-rapidos {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-rapido {
    width: 45px;
    height: 45px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    touch-action: manipulation;
}

.color-rapido:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.color-rapido.activo {
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
    transform: scale(1.1);
}

.botones-grosor {
    display: flex;
    gap: 8px;
}

.btn-grosor {
    padding: 10px 16px;
    border: 3px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    color: #333;
    touch-action: manipulation;
    min-height: 42px;
}

.btn-grosor:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-grosor.activo {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.btn-herramienta {
    padding: 0;
    border: 3px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 24px;
    transition: all 0.2s;
    color: #333;
    touch-action: manipulation;
    height: 52px;
    width: 52px;
    min-height: 52px;
    min-width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-herramienta:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-herramienta.activo {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.btn-fondo-rapido {
    width: 52px;
    height: 52px;
    border: 3px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.btn-fondo-rapido:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-zoom {
    padding: 0;
    border: 3px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 22px;
    transition: all 0.2s;
    color: #333;
    min-width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.btn-zoom:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.valor-zoom {
    font-weight: 600;
    color: #667eea;
    min-width: 60px;
    text-align: center;
    font-size: 16px;
    padding: 0 8px;
}

.grupo-herramientas label {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.grupo-herramientas input[type="color"] {
    width: 52px;
    height: 52px;
    border: 3px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    touch-action: manipulation;
}

.grupo-herramientas input[type="color"]:hover {
    transform: scale(1.1);
}

.grupo-herramientas input[type="range"] {
    width: 150px;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    cursor: pointer;
    touch-action: manipulation;
}

.grupo-herramientas input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: background 0.2s;
}

.grupo-herramientas input[type="range"]::-webkit-slider-thumb:hover {
    background: #764ba2;
}

.grupo-herramientas input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.grupo-herramientas input[type="range"]::-moz-range-thumb:hover {
    background: #764ba2;
}

#valor-grosor {
    font-weight: 600;
    color: #667eea;
    min-width: 50px;
    text-align: center;
    font-size: 16px;
}

.btn-accion {
    padding: 0;
    border: none;
    border-radius: 8px;
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    height: 52px;
    width: 52px;
    min-height: 52px;
    min-width: 52px;
    touch-action: manipulation;
}

.btn-grande {
    height: 52px;
    width: 52px;
    min-height: 52px;
    min-width: 52px;
    font-size: 24px;
}

.grupo-acciones {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-accion:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-accion:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-accion:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-limpiar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-guardar {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.contenedor-dibujo {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    order: 1;
    width: 100%;
    height: 100%;
}

#lienzo {
    display: block;
    cursor: crosshair;
    touch-action: none;
    width: 100%;
    height: 100%;
    background: white;
}

/* Responsive */
@media (max-width: 768px) {
    .barra-herramientas {
        padding: 15px;
        gap: 10px;
        min-height: auto;
    }
    
    .grupo-herramientas {
        padding: 10px 14px;
        gap: 10px;
    }
    
    .grupo-colores {
        min-width: auto;
        width: 100%;
    }
    
    .colores-rapidos {
        flex-wrap: wrap;
    }
    
    .color-rapido {
        width: 40px;
        height: 40px;
    }
    
    .btn-accion {
        padding: 12px 18px;
        font-size: 14px;
        min-height: 48px;
    }
    
    .btn-grande {
        padding: 14px 20px;
        font-size: 14px;
        min-height: 50px;
    }
    
    .botones-grosor {
        flex-wrap: wrap;
    }
    
    .btn-grosor {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .grupo-herramientas input[type="range"] {
        width: 100px;
    }
    
    .grupo-acciones {
        width: 100%;
        justify-content: center;
    }
}

